Speed up conda installs with mamba

Tingfeng | 2 min read | 03 January 2023 | [Python] #anaconda #conda #mamba

Conda and Mamba

Conda is an open-source package manager mainly used for managing Python environments.

Historically, installing and updating packages in conda environments was slow and tedious. This motivated QuantStack to create Mamba, a faster drop-in replacement solver for conda.

In December 2022, the conda project included mamba as a default solver, after 9 months in "experimental" status. This is great news for all conda users, however, mamba has to be manually installed and activated.

Here are 3 different ways to install mamba

Method 1: Use libmamba

To switch to the new libmamba solver, run the following commands:

# The following commands install and activate libmamba into the `base` environment
conda update -n base conda -y
conda install -n base conda-libmamba-solver -y
conda config --set solver libmamba

# Proceed to use conda as per normal

Method 2: Install mambaforge

Mambaforge can be installed instead of using an existing conda environment. This is the official recommendation of the mamba authors.

Method 3: Install mamba from conda-forge

It is also possible to install mamba onto an existing conda environment via the conda-forge channel. This is not recommended by the mamba authors. Furthermore, installing mamba into any other environment than base is not supported.

However, I have had no issues with this approach since 2019, but your mileage may vary. Consider yourself warned! Should you use this method, do it on a fresh conda environment to minimise the chances of complications.

# The following commands install mamba in the `base` environment via the conda-forge channel
conda config --add channels conda-forge
conda install mamba -n base -c conda-forge -y

# Use `mamba` in place of `conda`

# Install packages
mamba install numpy -y

# Uninstall packages
mamba uninstall numpy -y

# Update all packages
mamba update --all -y


Demonstrations by The Conda Team indicate that mamba package installs can be up to 6 times faster than conda. If you use conda, you should definitely give mamba a try.

More information

For more information on how to use mamba, refer to the documentation.