Friday, February 24, 2017

How to add another kernel in Anaconda

The latest release of Anaconda officially has Python 3.6 supported. However When I try to create a virtual environment to install TensorFlow 1.0, it complains no matching version found. So I have to create a virtual environment to install TensorFlow 1.0.

I probably too rush to do things, so I create a virtual environment by issuing:
conda create -n tensorflow

This is the nightmare begins. Later I realise I should clone things from the default root environment by issuing the following command:
conda create -n tensorflow --clone root

But that's another story.

Now activate it to install the proper python version:
conda search python
conda install python=3.5.3

To my surprise, when I start the notebook, only one kernel can be found. So it obviously we cannot expect things go as expected by just install python.

Seems now we need generate the kernel spec file for our current virtual environment
activate tensorflow
ipython kernel install

Generally the spec file will be created in the corresponding virtual environment directory of jupyter. Following the output of installation process to find it and do some modification. The most important one is changing the executable to the proper python.

When I try to start the notebook, it complains ipykernel couldn't be found.

So now let's install another packages:
conda install ipykernel
conda install ipywidgets

Now start the notebook, everything should be fine.