Simons Notes

Install multiple python kernels for IPython in ubuntu

July 26, 2015 | 0 Minute Read

Here is a quick one: Everytime I'm using python I struggle to select the correct version. Yes there is virtualenv, but to me this seems unnerving and distractful. So here is a way to install both python-kernels for python2 and python3 in ipython notebook. This way, you can choose which python version to use with a simple click

First you have to install both versions of python:

sudo apt-get install python python3

Then you may install IPython Notebook to python3 and install IPython for python2

sudo pip3 install "ipython[notebook]"
sudo pip2 install ipython

Last, you have to add both kernels to IPython Notebook:

sudo ipython kernelspec install-self
sudo ipython2 kernelspec install-self

You're done! Now you can start up IPython Notebook normally and everytime you create a new notebook, you may select the kernel to be used. Great!

ipython notebook