Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not running jupyter from a virtual environment? #1

Open
gregnordin opened this issue Dec 24, 2020 · 4 comments
Open

Not running jupyter from a virtual environment? #1

gregnordin opened this issue Dec 24, 2020 · 4 comments

Comments

@gregnordin
Copy link

I’m very interested in hearing your thoughts on the todo item:

Document rationale for one notebook server per user vs. running jupyter notebook in project's virtual environment

@bhrutledge
Copy link
Owner

bhrutledge commented Dec 26, 2020

Thanks for asking, @gregnordin! It's my understanding that Jupyter Notebook and Lab are intended to be standalone applications, running independently of a specific project. I think of it similarly to other applications like word processors, IDEs, and web browsers. Take Microsoft Word, for example: that will only be installed once per user, but it will be used to edit multiple documents. Similarly, I have one installation of Visual Studio Code, but I use it to work on multiple projects, each with a distinct development environment. With Jupyter Notebook/Lab, the document/project is the .ipynb file, and the development environment is the kernel.

It's certainly tempting to pip install jupyter into a project's virtual environment, because that's usually pretty easy. But, jupyter comes with lots of dependencies, which make your project's requirements larger than necessary, and could lead to conflicts. Furthermore, pip install is specific to Python projects, but one of the beauties of Jupyter is that it can run notebooks using kernels from all sorts of languages.

This has me thinking that it would be better to recommend installing Jupyter with a separate package manager (such as brew on macOS or apt on Ubuntu), or with pipx.

What are your thoughts?

@gregnordin
Copy link
Author

Thanks @bhrutledge--you make some very good points comparing jupyter to an application like MS Word. I hadn't thought of it that way. I have also found that trying to run two instances of jupyter at the same time, each from a different virtual environment, can mess things up in small ways.

My approach at this point is to create a virtual environment from which I only run jupyter and nothing else, and never jupyter from any other virtual environment. My approach is documented in this repo (note: I no longer follow the part about running jupyter from within other virtual environments).

That's an interesting idea about installing jupyter with a package manager, which I assume would take care of setting up an appropriate virtual environment for it like pipx does.

@bhrutledge
Copy link
Owner

Thanks for sharing!

My approach at this point is to create a virtual environment from which I only run jupyter and nothing else

I think that's the same approach suggested by this repo, except that I include installation of some frequently-used packages in the default kernel. I then leave it up to other projects' virtual environments to install kernel specs with their specific dependencies.

I'm going to leave this issue open as a supplement to the README, until I get around to updating it.

@gregnordin
Copy link
Author

@bhrutledge: sounds good!

I think our approaches are nearly the same, with the exception that I don't use the jupyter virtual environment as a jupyter kernel since I only have jupyter installed and want to keep it simple and clean. Instead, I have a separate anaconda virtual environment added as one of the available jupyter kernels that I access from within jupyter for generic situations when I don't need to go to the trouble of setting up a specific virtual environment for small projects. If I do need to set up a specific virtual environment for a project, I do the same thing as suggested in this repo.

The reason I have separated out anaconda in a separate virtual environment is that makes it easy to replace it with an updated version in the future. My main problem has been setting up python on my mac laptop and have it degrade and/or fall behind current versions as the years progress. My solution has been to make everything easily swappable and replaceable without affecting other virtual environments. This is documented in the link in my previous comment.

In any case, I appreciate you sharing your thoughts--I've found it to be quite helpful in clarifying some of my thinking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants