Multiple python version ipython notebook

http://stackoverflow.com/questions/30492623/using-both-python-2-x-and-python-3-x-in-ipython-notebook

The idea here is to install multiple ipython kernels. Here are instructions for anaconda. If you are not using anaconda, I recently added instructions using pure virtualenvs.

Anaconda 4.1.0

Since version 4.1.0, anaconda includes a special package nb_conda_kernels that detects conda environments with notebook kernels and automatically registers them. This makes using a new python version as easy as creating new conda environments:

conda create -n py27 python=2.7 ipykernel

conda create -n py35 python=3.5 ipykernel

After a restart of jupyter notebook, the new kernels are available over the graphical interface. Please note that new packages have to be explicitly installed into the new enviroments. The Managing environments section in conda’s docs provides further information.

Manually registering kernels

Users who do not want to use nb_conda_kernels or still use older versions of anaconda can use following steps to manually register ipython kernels.

configure the python2.7 environment:

conda create -n py27 python=2.7

source activate py27

conda install notebook ipykernel

ipython kernel install –user

configure the python3.5 environment:

conda create -n py35 python=3.5

source activate py35

conda install notebook ipykernel

ipython kernel install –user

After that you should be able to choose between python2

and python3 when creating a new notebook in the interface.

Additionally you can pass the –name and –display-name options to ipython kernel install if you want to change the names of your kernels. See ipython kernel install –help for more informations.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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