Enabling Single Users to create Multiple Virtual Environments for their notebooks

Hello Community,

I’m exploring solutions to enable users of our JupyterHub deployment to create and manage multiple virtual environments independently. Our setup is based on Kubernetes v1.28.2, and each user accesses their workspace through Jupyter Lab. The goal is to empower users to create distinct virtual environments for different notebooks directly within their session. For instance, User A logs in, initiates their Jupyter Lab session, and then sets up virtual environment ‘X’ for Notebook X, ‘Y’ for Notebook Y, and so on.

This approach would allow users to tailor their environment based on the specific requirements of each notebook. We aim to utilize the conda env command for creating these environments, ensuring a seamless experience for users to manage their virtual environments without external assistance.

If anyone has implemented a similar solution or knows of alternative methods to achieve this level of user autonomy in environment management, I’d greatly appreciate your insights. Any guidance, including relevant configurations or tools, would be immensely helpful.

Thank you for your support!

Users can do this now in a terminal in JupyterLab by running:

# create the env
# it must have a kernel package in it (`ipykernel` for IPython, or another kernel package if a different language)
conda env create -n my-project-name ipykernel ...other packages...
# register the env as a kernel named 'my-project', available to JupyterLab
conda run -n my-project-name python3 -m ipykernel install --user --name my-project