Installing Julia Kernel in on existing Jupyter Server

Tested on Ubuntu 16.04, but should work similar with other distributions.

Building the Kernel

Start the Julia REPL and execute the following

Pkg.add("IJulia")

At the end of the download and building process you should see a line similar to Writing IJulia kernelspec to /home/a/.julia/v0.5/IJulia/deps/julia-0.5/kernel.json .... This means the jupyter kernel has been built.

Now we only have to add it to the existing jupyter installation.

Installing the Julia Kernel

In the shell type

sudo jupyter kernelspec install /home/a/.julia/v0.5/IJulia/deps/julia-0.5

The concrete path obviously depends on the information you got in the previous step.

Virtualenv

If you are using a virtualenv you might notice that sudo does not work. This is because the virtualenv is not sourced in the sudo context. If this is the case, switch to a root shell using sudo su, source the virtualenv and then install the kernel.

Getting Julia To Work Together With Python

You might have some problems using e.g. PyCall or PyPlot after installing Julia like this. To ensure that everything works proprely you should manually set the environment varibles PYTHON, PYTHONPATH, and PYTHONHOME.

  • PYTHON : Set to the absolute path of the python interpreter used
  • PYTHONPATH : Set to the directories where packages can be found. A good way to determine this is to start a python interpreter where everything is working and use the content of sys.path as the directories of PYTHONPATH
  • PYTHONHOME : Should be set to the directory containing the /lib directory of your python installation

Here are the values that I have set (I added the exports at the end of the activate script of my virtualenv)

export PYTHONPATH=/home/sebastian/Python3.5.2/lib/python35.zip:/home/sebastian/Python3.5.2/lib/python3.5:/home/sebastian/Python3.5.2/lib/python3.5/plat-linux:/home/sebastian/Python3.5.2/lib/python3.5/lib-dynload:/home/sebastian/py3env/lib/python3.5/site-packages:/home/sebastian/py3env/lib/python3.5/site-packages/Keras-2.0.3-py3.5.egg
export PYTHONHOME=/home/sebastian/Python3.5.2
export PYTHON=/home/sebastian/Python3.5.2/bin/python3

Author: Sebastian Stabinger

Email: firstname@lastname.name

Created: 2018-01-01 Mon 20:07

Emacs 25.3.1 (Org mode 8.2.10)

Validate