Python Virtual Environment Setup

Python
Author

Kunlei Lian

Published

February 20, 2024

Just save the list of commands I use frequently to create virtual environments and make them available to jupyter notebooks.

# create a new virtual environemnt named 'env_name'
conda create -n 'env_name'

# activate the newly created virtual environment
conda activate 'env_name'

# list all available environments
conda env list

# remove an virtual environment
conda env remove -n 'env_name'

# install ipykernel
pip install --user ipykernel

# add the virtual environment to jupyter
python -m ipykernel install --user --name='env_name'

# list available jupyter kernels
jupyter kernelspec list

# remove kernel from jupyter
jupyter kernelspec uninstall 'env_name'