A comprehensive reference for managing Jupyter kernels across conda environments and using them in PyCharm. Perfect for ML/DL practitioners who work with multiple conda environments.
- Prerequisites
- Installing ipykernel
- Creating Custom Kernels
- Listing Kernels
- Removing Kernels
- Restoring Kernels
- Using Kernels in PyCharm
- Using Kernels in Jupyter Notebook/Lab
- Managing Multiple Environments
- Troubleshooting
- Quick Reference Cheatsheet
- Anaconda or Miniconda installed
- At least one conda environment created
- PyCharm (Professional or Community) installed
conda create -n my_env python=3.10
conda activate my_envipykernel must be installed inside each conda environment you want to use as a kernel.
conda activate my_env
conda install ipykernelconda activate my_env
pip install ipykernelconda install -n my_env ipykernelAfter installing ipykernel, register the environment as a Jupyter kernel.
conda activate my_env
python -m ipykernel install --user --name my_env --display-name "My Environment"| Parameter | Description |
|---|---|
--user |
Installs kernel for current user only (recommended) |
--name |
Internal kernel name (no spaces, used in commands) |
--display-name |
Human-readable name shown in PyCharm/Jupyter UI |
# ML environment
conda activate ML_Unsupervised
python -m ipykernel install --user --name ML_Unsupervised --display-name "Conda (ML Unsupervised)"
# Deep Learning environment
conda activate DL_Architecture_Generative
python -m ipykernel install --user --name DL_Generative --display-name "Conda (DL Generative)"
# Data Engineering environment
conda activate data_eng
python -m ipykernel install --user --name data_eng --display-name "Conda (Data Engineering)"β Registered kernels are permanent β they survive terminal closes, system restarts, and PyCharm restarts.
jupyter kernelspec listAvailable kernels:
ml_unsupervised C:\Users\username\AppData\Roaming\jupyter\kernels\ml_unsupervised
dl_generative C:\Users\username\AppData\Roaming\jupyter\kernels\dl_generative
python3 C:\Users\username\anaconda3\share\jupyter\kernels\python3
| OS | Default kernel path |
|---|---|
| Windows | C:\Users\username\AppData\Roaming\jupyter\kernels\ |
| macOS | ~/Library/Jupyter/kernels/ |
| Linux | ~/.local/share/jupyter/kernels/ |
jupyter kernelspec remove kernel_namejupyter kernelspec remove kernel1 kernel2 kernel3# Remove default python3 kernel
jupyter kernelspec remove python3
# Remove a custom kernel
jupyter kernelspec remove ml_unsupervised
# Remove multiple at once
jupyter kernelspec remove python3 dl_generative
β οΈ You will be prompted[y/N]β typeyto confirm each removal.
π‘ Removing a kernel does not delete the conda environment β only its Jupyter registration.
Removed kernels can always be re-registered with the same command used to create them.
conda activate my_env
python -m ipykernel install --user --name python3 --display-name "Python 3"conda activate ML_Unsupervised
python -m ipykernel install --user --name ML_Unsupervised --display-name "Conda (ML Unsupervised)"- Go to File β Settings (
Ctrl+Alt+S) - Navigate to Project β Python Interpreter
- Click the dropdown β Add Interpreter β Add Local Interpreter
- Choose System Interpreter
- Browse to your conda env's
python.exe:# Windows C:\Users\username\anaconda3\envs\my_env\python.exe # macOS/Linux /Users/username/anaconda3/envs/my_env/bin/python - Click OK
- Go to File β Settings β Languages & Frameworks β Jupyter β Jupyter Servers
- Select "IDE-Managed Server" (set to Auto)
- Click OK
β PyCharm will auto-start/stop Jupyter β no manual commands needed.
- Open any
.ipynbfile in PyCharm - Look at the top-right corner of the notebook editor
- Click the kernel dropdown
- Select your registered kernel (e.g.
Conda (ML Unsupervised))
- Top-right dropdown β select a different kernel
- PyCharm will restart the kernel automatically
conda activate base
jupyter notebook
# or
jupyter lab- Jupyter Notebook: Kernel menu β Change Kernel β select your env
- JupyterLab: Click kernel name in top-right β select your env
Install nb_conda_kernels in base to auto-detect all conda environments:
conda install -n base nb_conda_kernelsThen start Jupyter from base β all envs appear as kernels automatically.
# Create environments
conda create -n project_ml python=3.10
conda create -n project_dl python=3.11
# Install ipykernel in each
conda activate project_ml
conda install ipykernel
python -m ipykernel install --user --name project_ml --display-name "Project ML"
conda activate project_dl
conda install ipykernel
python -m ipykernel install --user --name project_dl --display-name "Project DL"
# Verify
jupyter kernelspec listThe kernel name is stored in the notebook's metadata β visible in the top-right of PyCharm/Jupyter.
# Re-register the kernel
conda activate my_env
python -m ipykernel install --user --name my_env --display-name "My Env"
# Then restart PyCharm# Check if Jupyter is running
jupyter notebook list
# Kill all running Jupyter servers
jupyter notebook stop# Verify which Python the kernel uses
conda activate my_env
python --version
# Then re-register
python -m ipykernel install --user --name my_env --display-name "My Env (Python 3.10)"# Check if all required packages are installed in the env
conda activate my_env
conda list
# Reinstall ipykernel
conda install --force-reinstall ipykernel- Go to Settings β Jupyter β Jupyter Servers
- Switch to "IDE-Managed Server"
- This makes PyCharm handle the server automatically
# List all kernels to find duplicates
jupyter kernelspec list
# Remove duplicates
jupyter kernelspec remove duplicate_kernel_name# Installing ipykernel
conda activate my_env
conda install ipykernel
# creating kernel servers
python -m ipykernel install --user --name env_name --display-name "UI_display_name"
# listing all kernels
jupyter kernelspec list
# removing kernels
jupyter kernelspec remove kernel_name # remove one
jupyter kernelspec remove k1 k2 k3 # remove multiple
# restoring kernels
python -m ipykernel install --user --name env_name --display-name "UI_display_name"
# Jupyter Notebook commands
jupyter notebook list # list running servers
jupyter notebook stop # stop all servers
jupyter lab # start JupyterLabFeel free to open issues or pull requests for additional tips, OS-specific instructions, or new troubleshooting entries.
MIT License β free to use, share, and modify.