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 includes the steps described here, so you do not need to execute them again!

This works fine in single jupyter notebooks using the start-jupyter script on Mistral. Nevertheless, 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. 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

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