Intalling Jupyter in a virtualenv

Took me a few tries to get this working, since I started incorrectly and also did not want anaconda.


activate your virtualenv
$ cd tensorflow
$ source bin/activate
(tensorflow)$ pip install –upgrade pip
(tensorflow)$ pip install ipython
(tensorflow)$ pip install jupyter


(tensorflow)$ which python
(tensorflow)$ which ipython
(tensorflow)$ which jupyter-notebook
(I accidentally removed /usr/local/bin/jupyter which I suspect was a link to/usr/local/bin/jupyter-notebook)

Add Kernel

(tensorflow)$ ipython kernelspec install-self –user
This will create a kernelspec for your virtualenv and tell you where it is:
[InstallNativeKernelSpec] Installed kernelspec pythonX in /home/username/.local/share/jupyter/kernels/pythonX
Where pythonX will match the version of Python in your virtualenv.

Copy the new kernelspec somewhere useful. Choose a kernel_name for your new kernel that is not python2 or python3 or one you’ve used before and then:

(tensorflow)$ mkdir -p ~/.ipython/kernels
(tensorflow)$ mv ~/.local/share/jupyter/kernels/pythonX ~/.ipython/kernels/<kernel_name>
Change the name of the kernel that IPython shows, edit ~/.ipython/kernels/<kernel_name>/kernel.json and change the JSON key called display_name to tensrflow.

You should now be able to see your kernel in the IPython notebook menu: Kernel -> Change kernel and be able so switch to it (you may need to refresh the page before it appears in the list). IPython will remember which kernel to use for that notebook from then on.

(thanks to pythonanywhere:


(tensorflow)$ jupyter-notebook
this will open up a browser tab in chrome
In the browser, run a simple test:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s