Adding a Python Environment to Open OnDemand JupyterLab

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

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

           
    ​​​​​​​
     

Details

Details

Article ID: 24765
Created
Wed 4/2/25 9:57 AM
Modified
Mon 4/7/25 2:56 PM