IntroductionGetting started with mamba
mamba and micromamba are general software package managers for any kind of software and all operating systems (currently supported are Windows, macOS and many Linux distributions). A software package manager lets developers install the libraries and applications they need to work efficiently. Mamba is a great choice because it's mature, fast and robust.
With mamba it's easy to setup
A software environment is simply a set of different libraries, applications and their dependencies.
The power of environments is that they can co-exist: you can easily have an environment called py27 for Python 2.7 and one called py310 for Python 3.10, so that multiple of your projects with different requirements have their dedicated environments.
This is similar to "containers" and images.
However, mamba makes it easy to add, update or remove software from the environments.
Historically we have been working on mamba, and later started
If you are starting fresh, we recommend
micromamba these days.
The installation of
micromamba is straight forward:
Execute the following on a terminal (or download the micromamba binary manually from Github releases.
bash -c "$(curl https://micromamba.pfx.dev/install.sh)"
You can also use
zsh (preferred on macOS):
zsh -c "$(curl https://micromamba.pfx.dev/install.sh)"
The script installs the
micromamba executable to
During the installation you will be asked if you want to "initialize" your shell for micromamba. This adds some hooks into your
.bashrc file (Windows & macOS:
~/.bash_profile), on zsh the
~/.zshrc file. Micromamba will tell you exactly what hooks are added, and they can be removed by running
micromamba shell deinit later on.
Without initializing the shell,
micromamba activate does not properly function. However, you can still use
micromamba run -n myenv <my command> to run commands from
On Windows, you can execute the following script from Powershell to install micromamba.
Invoke-Expression ((Invoke-WebRequest -Uri https://micromamba.pfx.dev/install.ps1).Content)
The script downloads
micromamba.exe and places it in
This path is also added to the PATH environment variable.
The script also asks to initialize your Powershell for usage with
micromamba activate. If you initialize the shell, a code snippet is added to your
The first step when using micromamba is to create an environment.
In order to create an environment, one needs to also specify a "channel".
Channels are the software repositories from which the packages are downloaded.
We recommend the
conda-forge channel and are going to use it in this example.
The following line will create a new environment with the name
myenv, using the
conda-forge channel to get the packages, and install
micromamba create --name myenv --channel conda-forge jupyterlab # the equivalent short form is micromamba create -n myenv -c conda-forge jupyterlab
The environment creation will do four things:
- first, it downloads the channel index that contains all packages
- then it solves for jupyterlab and selects specific versions of all the required dependencies (such as
- it then asks the user for confirmation and starts downloading & extracting the packages to the package cache
- once the download and extraction is finished, mamba "links" the packages into the target environment. The environment is a specific folder on your disk that contains the files of all packages
To use the environment, one can run
micromamba activate myenv
After the activation is executed, one can see a
$ (myenv) ... in the shell which indicates the current activated environment.
The activation makes all software available from the command line.
Since we installed
jupyterlab, we can now execute
jupyterlab on the shell which would start the
Another way to use the installed software is via
The following code also executes the
jupyterlab version that was installed in the
micromamba run -n myenv jupyterlab
The active environment can also be modified using
micromamba install xeus-sqlite to install the
xeus-sqlite jupyter kernel or
micromamba update jupyterlab to update to a newer version of jupyterlab if one is available.