Micromamba
Micromamba is a statically linked C++ executable that provides the full power of the Conda ecosystem without needing a pre-installed Python "base" environment. Unlike pip, uv and other package managers, Conda can manage libraries written in C, C++, or R, which is vital for machine learning and AI work.
INFO
When to use: Micromamba is preferred for projects requiring polyglot or non-Python dependencies; for repositories strictly focused on the Python ecosystem, uv remains the optimized choice.
Installation
yay micromamba-binInitialize and Verify
micromamba shell init -s bashINFO
If the command above fails, run this before repeating the same step again: export MAMBA_ROOT_PREFIX=~/micromamba
source ~/.bashrc
micromamba --versionIf you need activation support only for current shell session, you can load shell hook manually instead:
eval "$(micromamba shell hook -s bash)"
micromamba activate <env_name>Channels
Micromamba pulls packages from channels. In practice, many scientific and data packages are commonly installed from conda-forge.
micromamba config append channels conda-forge
micromamba config set channel_priority strictTIP
Strict channel priority helps keep dependency resolution more predictable.
Computational Workstations & Shared Environments
On shared computational workstations (e.g. kmer), micromamba is often pre-installed with a shared conda root.
Verify installation
micromamba --version
micromamba infoMake sure the root prefix is set correctly (example):
/home/ndemo/.condaCreate a personal environment
micromamba create -n test python=3.12 numpy scipy -yActivate and verify it:
micromamba activate test
which python
python --versionThe expected path should look like:
/home/ndemo/.conda/envs/test/bin/pythonDeactivate when done:
micromamba deactivateCreate and use shared environments (managed by root)
On shared servers, system administrators can create environments in a shared location (e.g. /data/conda/shared_envs/) that all users can activate.
WARNING
Only root/administrators can create or update shared environments.
As root:
micromamba create \
-p /data/conda/shared_envs/scientific \
-c conda-forge \
python=3.12 numpy scipy pandas matplotlib \
-yAs any user, you can activate it directly by path:
micromamba activate /data/conda/shared_envs/scientificTo add packages to a shared environment, only the administrator can do so:
micromamba install \
-p /data/conda/shared_envs/scientific \
scikit-learn -yCore Workflow
WARNING
Don't "brainlessly" run the following commands, since you need to replace the <> values.
Environment Management
Create
# The basics: environment creation
micromamba create --name <env_name> python=3.11# You can target specific packages, versions and channels (like conda-forge)
micromamba create -n <env_name> -c conda-forge python=3.11 <packages># Environments can be built given an existing .yml file
# NOTE: You can specify the environment name adding "-n <env_name>".
micromamba create -f <filename>.yml# Keep the environment physically inside the project folder
# (like a .venv) instead of Micromamba's central registry.
# NOTE: To activate this later, you will need to point to the path:
# micromamba activate ./env
micromamba create -p ./env python=3.11 <packages>Example environment.yml:
name: myenv
channels:
- conda-forge
dependencies:
- python=3.11
- numpy
- pipOnce created, don't forget to always activate your environment:
micromamba activate <env_name>TIP
Micromamba also allows you to run a command inside an environment without activating it first:
micromamba run -n <env_name> python <script_name>.pyAt some point, you may also want to temporarily "quit" your environment:
micromamba deactivateDelete
# Remove the environment. Cleanly
micromamba env remove -n <env_name># You can target the environment either by its name or its directory path
micromamba env remove -p ./env_folderTIP
Alternatively, you can skip the word env entirely by utilizing the standard package removal command paired with the --all flag (which instructs Micromamba to strip away all packages, wiping out the environment).
Extra
# For the sake of clarity, better check the existing ones
micromamba env list# As they can be imported, environments can be also exported to .yml files
micromamba env export > environment.ymlPackage Management
# Install a package. Or more, just list them
# You can optionally specify their version (<package_name=version_number>)
micromamba install <package_name># Remove a package from the environment
micromamba remove <package_name># Update a package. Better than reinstalling it
micromamba update <package_name># Search for packages and channels
micromamba search <package_name># Gives a list of all the packages in the environment
micromamba list# Installing packages builds up cache. Give it a flush, sometimes
micromamba clean --all