This is a short but very useful post.
The new Jupyter/IPython architecture accepts multiples kernels, one can run
R
, Julia
, Haskell
and many other languages. Here is list of kernels
that are available for installation:
It is possible to run all those languages taking advantage of the rich literate programming capabilities of the notebook.
One cool feature is the possibility to switch from one language to another using a drop down menu (upper right of the notebook).
However, I do not use any of those in my everyday work. I do use a variety of python installations though. And that drop down menu looks very interesting to me.
In my current setup I use Virtual environments created with virtualenvwrapper, conda, system python3 (my default), system python2 and many others.
With Jupyter/IPython new kernel logic it is possible to roll your own kernel.
Here, instead of creating my own, I just created some kernels.json
files
that point to my custom python installations:
%%bash
# Default.
ipython_config_dir=$(ipython locate config)
cat $ipython_config_dir/kernels/python3/kernel.json
%%bash
# Virtualenvwarpper python 2 with iris.
ipython_config_dir=$(ipython locate config)
cat $ipython_config_dir/kernels/iris_python2/kernel.json
%%bash
# Miniconda python 2 with ioos channel.
ipython_config_dir=$(ipython locate config)
cat $ipython_config_dir/kernels/ioos_python2//kernel.json
And now I can switch from one environment to another with the drop down menu. It is that simple! There is no need to install anything extra because they are all python environments.
Here is the result:
from IPython.display import Image
Image('../../figures/jupyter_kernels.png')
Now I do not need to open several notebook instances to change from one environment to another ever again!
HTML(html)