Summary
This article explains how to add a custom Python environment to your Open OnDemand JupyterLab. By following the steps below, you will create a virtual environment, install the necessary packages, and register it as a new kernel for JupyterLab.
Body
When to Use?
This guide is designed for those who need to set up a dedicated Python environment to manage project-specific dependencies without impacting the system-wide installation. Use it when you require a reproducible, isolated development setup in Open OnDemand JupyterLab or when troubleshooting environment issues.
Procedure
Step 1: Open a Terminal in JupyterLab
- Launch JupyterLab via Open OnDemand and open a new terminal window. This terminal will be used to run all the commands in the steps that follow.
Step 2: Create and Activate a Virtual Environment
- Create a new virtual environment using the
venv
module. Replace test_venv
with a name of your choice. Run the following commands:
- python -m venv test_venv
- source test_venv/bin/activate
- pip install ipykernel

Step 3: Register the Environment with Jupyter
- Once the virtual environment is set up and activated, register it with Jupyter using the command below. You can change
"myvenv"
to a name that better identifies your environment:
- python -m ipykernel install --user --name "myvenv"

Final Note:
- After completing these steps, you can select your newly created environment from the JupyterLab launcher, and it will operate as an independent Python kernel
