I am using JupyterLab notebooks in JupyterHub multi user environment.
I would like to set up some environment variable dynamically based on what kernel is chosen by the user in the active notebook. Imagine this variable could be a virtualenv name that gets switched from “kernel_A” to “kernel_B” whenever a user changes “kernel_A” to “kernel_B” in their current notebook.
Has anyone come up with a smart solution how to do it?
There are a couple of suggestions on this forum:
- If the variable is static for a given kernel you could set it in the kernel spec: How can I pass environment variabel PYTHONPATH to jupyter notebook? - #2 by kevin-bates
- If you the variable is more dynamic you could use a wrapper script: Unable to reliably use single JypyterLab server with multiple conda environments - #3 by jonburdo
1 Like