Mamba and Its Usage

Page content

What is Mamba?

mamba is a reimplementation of the conda package manager in C++.

  • parallel downloading of repository data and package files using multi-threading

  • libsolv for much faster dependency solving, a state of the art library used in the RPM package manager of Red Hat, Fedora and OpenSUSE

  • core parts of mamba are implemented in C++ for maximum efficiency

At the same time, mamba utilizes the same command line parser, package installation and deinstallation code and transaction verification routines as conda to stay as compatible as possible.


We recommend that you start with the Mambaforge distribution. Mambaforge comes with the popular conda-forge channel preconfigured, but you can modify the configuration to use any channel you like. Note that Anaconda channels are generally incompatible with conda-forge, so you should not mix them.

Download and install

wget -c

sh /your/path/

Conda/Mamba initialize

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('$HOME/mambaforge/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
    if [ -f "$HOME/mambaforge/etc/profile.d/" ]; then
        . "$HOME/mambaforge/etc/profile.d/"
        export PATH="$HOME/mambaforge/bin:$PATH"
unset __conda_setup
# <<< conda initialize <<<

# >>> mamba initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__mamba_setup="$('/home/sdy/mambaforge/bin/mamba' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__mamba_setup"
    if [ -f "$HOME/mambaforge/etc/profile.d/" ]; then
        . "$HOME/mambaforge/etc/profile.d/"
        export PATH="$HOME/mambaforge/bin:$PATH"
unset __mamba_setup
# <<< mamba initialize <<<
conda install -n base --override-channels -c conda-forge mamba 'python_abi=*=*cp*'

Set conda official source

conda config --add channels r
conda config --add channels bioconda
conda config --add channels conda-forge

Conda virtual environment

# Create a new dedicated environment (you can choose your own environment name)
# Where -n stands for name, env_name is the name of the environment to create, and list of packages is the list of toolkits to install in the new environment.
mamba create -n env_name list of packages

# Activate the environment
mamba activate bx_exp

# Conduct subsequent experiments, and exit the environment after finishing experiments:
mamba deactivate bx_exp

# If this environment is no longer needed, you can delete it
mamba env remove -n new_env

# Display all environments:
mamba env list

Mamba install software

# Search for conda packages, will show versions and sources of the package
mamba search edger

# Can specify version to install
mamba install numpy=1.10

# View all packages
mamba list

# Update a package
mamba update pack_name

# Update all packages
mamba update --all

# Remove a package
mamba remove package_name

Export and import of conda virtual environment

#Assume we have an environment called bioapp, we can export it to a yml file
mamba env export --file bioapp.yml --name bioapp

# Then on another computer, we can fully reproduce this environment
# Another advantage of doing this is the software versions are explicitly listed in the yml
# Using conda solving environment will be much faster
mamba env create -f bioapp.yml

Use conda-pack to copy directly from the installed location (same operating system)

#Install conda-pack
mamba install -c conda-forge conda-pack

#Pack the installed environment
conda pack -n my_env_name -o my_env_name.tar.gz

# Copy the packed environment my_env_name.tar.gz to the target machine, and decompress it to any directory, generally recommended under envs directory (anaconda_root/envs). (Note: replace anaconda_root with your own conda install path.)
# Decompress the packed environment
# It will decompress everything to current directory by default, quite spectacular -C must be specified
mkdir -p anaconda_root/envs/my_env
tar -xzf my_env.tar.gz -C anaconda_root/envs/my_env

#Activate environment
mamba activate my_env/bin/activate


#The environment is now fully copied
mamba deactivate


  1. miniforge
  2. mamba
  3. Mamba Installation