Conda and Mamba Commands for Managing Virtual Environments

2 min read

Installing Mamba

conda install -n base -c conda-forge mamba

Adding channels

conda config --add channels conda-forge

Updating Mamba

mamba update -n base mamba

Finding a Package

mamba repoquery search PACKAGE

Searching for dependencies

mamba repoquery depends -a PACKAGE

Creating an environment

mamba create -n ENV_NAME PACKAGE

Adding/Updating software

mamba install -n ENV_NAME PACKAGE
mamba update -n ENV_NAME --all

Removing a package

mamba remove -n ENV_NAME PACKAGE

Undoing changes to an environment

mamba list -n ENV_NAME --revisions
mamba install -n ENV_NAME --revision 1

Show environment

conda env export --no-builds

Clone an existing environment

conda create --name CLONE_ENV_NAME --clone ENV_NAME

Removing an environment

mamba env remove -n ENV_NAME
conda remove --name ENV_NAME --all

Exporting an environment

mamba env export -n ENV_NAME > ENV_NAME.yaml
conda list -e > ENV_NAME.txt
conda env export -n ENV_NAME | findstr -v "prefix" > ENV_NAME.yaml
conda env export -n ENV_NAME --no-builds | grep -v "prefix" > ENV_NAME.yaml

Importing an environment

mamba env create --file ENV_NAME.yaml
conda env create --file ENV_NAME.yaml
conda create -n ENV_NAME --file ENV_NAME.txt

Deactivate the Environment

conda deactivate

Viewing a list of your environments

conda info --envs
conda env list
 Data Science