How to enable user specific kernels like PY2, PY3 and R in Jupyterhub

This will depend on what Spawner you use. If it is a shared system as with the default or systemd spawners, to make kernels available for all users, you can install them system- or env-wide. If you want kernels to only be available for one user, you can install the kernels for just that user. Check jupyter kernelspec list to see the paths where kernels are installed. You can move them to other locations on jupyter --paths (the data directories) that are per-user.

If you want to set the default kernel whitelist on a per-user basis, you can do this in jupyter configuration:

# /etc/jupyter/jupyter_config.py
import os
jupyterhub_user = os.environ.get("JUPYTERHUB_USER")
if jupyterhub_user and jupyterhub_user in {'myname', 'othername'}:
    # only the 'ir' kernel is allowed for these users:
    c.KernelSpecManager.whitelist = {"ir","pyspark"}

The keys in that set should be the keys you see in jupyter kernelspec list.

1 Like