This cheatsheet contains all the commands that I use to manage my Python virtual environments with Conda. I also included some Pip commands at the bottom of the page.
Install Conda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && bash Miniconda3-latest-Linux-x86_64.sh
Create a new environment
conda create -n myenv python=3.8
Clone an environment
conda create -n myclone --clone myenv
List all the Conda environments
conda env list
Delete an environment
conda deactivate myenv
conda remove -n myenv --all
Save and load an environment with Conda
- Save the environment:
conda list --export > requirements.txt
- Load the environment:
conda create --name myenv --file requirements.txt
Save and load an environment with Pip
If you created your environment with Conda, I recommend saving it with Conda because the output of pip freeze
might contain the names of Conda packages that Pip will be unable to find later.
- Save the environment:
pip freeze > requirements.txt
- Load the environment:
pip install -r requirements.txt
Install a package in developper mode with Pip
pip install -e .