Enable NCL Kernel in Jupyterhub#

Issue#

  • Can’t use NCL (Python) as kernel in Jupyter

  • This tutorial won’t work

In order to use NCL in Jupyter notebooks you need to install this in your conda env. The setup.py already includes the steps described in Kernels, so you do not need to execute instructions again!

For Jupyterhub, there is an additional step to do after installing the kernel.

Solution#

The solution is to add the location of the conda env to the PATH using the kernel.json.

How?#

The easiest way to add path to missing library is to modify the kernel.json as described here <own_kernel>. For the ncl example, the original generated kernel.json looks like this:

{
"argv": [
  "/path/to/your/conda_env/bin/python",
  "-m",
  "ncl_kernel",
  "-f",
  "{connection_file}"
],
"display_name": "NCL",
"language": "ncl",
"name": "ncl_kernel"
}

The modified kernel.json should look like this:

{
"argv": [
  "/path/to/your/conda_env/bin/python",
  "-m",
  "ncl_kernel",
  "-f",
  "{connection_file}"
],
"display_name": "NCL",
"language": "ncl",
"name": "ncl_kernel",
"env": {
"PATH":
       "$PATH:/path/to/your/conda_env/bin"
       }
}

You need to restart the kernel after you change this.

Note

Currently, the installation fails with IPython < 4 due to this line. The workaround is to import from the paths and not from utils.path.

Note

kernel.json can be found in .local/share/jupyter/kernels/your_kernel/.