Custom Conda Environment in JupyterLab
This tutorial walks you through creating a new conda environment and making it available as a selectable kernel in JupyterLab.
Step 1: Start a JupyterLab Session and Open a Terminal
Start your JupyterLab session.
Open a new Terminal.
Step 2: Create a New Conda Environment
In the terminal, create a new conda environment. Replace myenv with your preferred environment name and specify your desired Python version. If prompted to proceed with installing new packages, type y.
💡 Tip: You can name your environment anything you like. Using a descriptive name helps when managing multiple environments.
Step 3: Activate the Environment
Your terminal prompt should update to reflect the active environment, e.g., (myenv).
Step 4: Install ipykernel and Other Packages
With the environment active, install the ipykernel package (required) along with any other packages needed in your conda environment, replacing the example packages below with whatever your project requires:
💡 Tip: Whenever you need to install additional packages into this environment in the future, open a Terminal in JupyterLab, activate the environment with
conda activate myenv, and then run yourpip installorconda installcommand.
Step 5: Register the Environment as a Jupyter Kernel
Run the following command to make your conda environment visible as a selectable kernel in JupyterLab:
| Flag | Description |
|---|---|
--user |
Installs the kernel for the current user only |
--name |
Internal name used to identify the kernel |
--display-name |
The name shown in the JupyterLab UI |
Step 6: Select Your Kernel and Start Working
After a moment, open a new tab in JupyterLab. In the Notebook section of the Launcher, you should now see your new environment listed as a kernel option alongside the default:
Python 3 (ipykernel)(default)Python(myenv)✅ (your new environment)
To start a new notebook using your environment, click the Python(myenv) icon in the Launcher.
To switch the kernel in an existing notebook, click the kernel name in the top right corner (next to the small bug icon) and select Python(myenv) from the dropdown.
Summary
conda create -n myenv python=3.11
conda activate myenv
pip install ipykernel numpy pandas matplotlib
python -m ipykernel install --user --name myenv --display-name "Python(myenv)"
Once registered, your environment will persist as a kernel option in JupyterLab until you explicitly remove it.
To install additional packages in the future: