Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different virtualenv's on one Jupyter notebook

I am working on a setup where several developers, working on different projects, all execute their code on a remote machine, using Jupyter notebook.

Since every projects requires a different virtualenv what happens now is that every developer for every projects, sets up a project specific virtualenv, installs notebook to it, runs it on a different port and connects to the remote machine through that port.

Is there a way to have 1 Jupyter notebook running on the remote machine, but be able to choose which virtualenv to use as kernel?

My main consideration is being able to expose only one port on the remote machine, but be able to use different virtual python environment for running the notebooks

like image 387
bluesummers Avatar asked Nov 30 '17 10:11

bluesummers


People also ask

Can multiple people work on one Jupyter Notebook?

The new collaborative editing feature enables collaboration in real-time between multiple clients without user roles, when sharing the URL of a document to other users, they will have access to the same environment you are working on (they can write and execute the cells).

How do different environments work in Jupyter notebooks?

You can also create new environments from within Jupyter Notebook (home screen, Conda tab, and then click the plus sign). And you can create a notebook in any environment you want. Select the "Files" tab on the home screen and click the "New" dropdown menu, and in that menu select a Python environment from the list.

Can you use multiple languages in Jupyter Notebook?

You may know that Jupyter has several dozen kernels in as many languages, and that you can choose any of them to power the code execution in a single notebook.


Video Answer


1 Answers

I am working on a setup where several developers

If you have many dev working on a remote machine you must use JupyterHub, JupyterHub is made for that, and JupyterHub is the first step toward easing your pain; if you do not use JupyterHub, things will go wrong.

Once you have JupyterHub installed, your devs will be able to login with their credential wit exposing a single port, and will be able to start/stop notebook servers without sshing in.

Once this is done, you can investigate multiple venv.

In each environment you want to install ipykernel. It is the module that knows how to talk to the notebook. And in each environment you need to issue the python -m ipykernel install --user --name=my-env-name as said in the comments below your posts. This register each env with Jupyter, telling it "Hey I exist expose me to your users". You may also decide to install this that does part of this automatically for you, but have some caveats.

As other commenters have pointed out you likely want to read Jake's post, and if you have several users you should absolutely always almost without questions use JupyterHub.

like image 97
Matt Avatar answered Sep 26 '22 09:09

Matt