I’m started using jupyter hub, it’s very nice and useful (and on NixOS it is a very), but I’m missing an important feature: the ability to create multiple environment and python versions.
Currently I’m using uv which does the job flawlessly, but each user has their own jupyter notebook/lab instances, no sharing, no auth and so on. So I wonder how uv could be integrated in jupyterhub. Ideally, one would be able to create/manage from the UI multiple environments and create notebook in those environments.
I couldn’t find a FAQ or a comprehensive page on this in the documentation, but maybe it’s common knowledge that I didn’t learn yet. What is the current best practice for this?
My understanding is that on JupyterHub, the administrator can pre-configure some images with pre-installed kernels and each kernel can use it’s own environment.
Users can also create their own environments. One option is to create a environment based on a Git repository using BinderHub.
Actually, I found a solution: it’s possible to register custom kernels from inside running jupyterlab instances, therefore to use custom uv environments it’s possible to do something like this:
create a virtual environment with $ uv venv --python 3.10 my-env
activate it, e.g. $ . my-env/bin/activate
install ipykernel in that environment: (my-env)$ uv pip install ipykernel
register the kernel: (my-env)$ python -m ipykernel install –user --name=my-env
refresh the jupyterlab web page (this will not stop the kernels)
the kernel can now be used, e.g. go to an open notebook → kernel → change kernel
This should work in jupyterlab in general (and it’s not intimately tied to uv), so works on hub as well. It’s not the most elegant solution, but gives users quite some freedom.