Package managers conda & mamba
In order to have a recent Python version, it is often more convenient and quick to use package manager software to install a full Python environment. These package managers allow to install, not only Python and some of its main modules, but all the required system dependancies, without the need of any compilation.
There are two main package managers usually used for installing and managing several Python version:
Anaconda and Miniconda distributions based on the
conda
command line interface,Mamba and Micromamba distributions based on the
mamba
CLI (micromamba
being a lighter version ofmamba
).
The command line interface (CLI) of these package managers also offer commands to create and manage multiple Python environment, in a robust way. They also provide access to a large software collection through specific channels. However, let’s note that some of these softwares, especially those provided by the default channels in Anaconda, are under the Anaconda license.
Note
Different releases are available at CC-IN2P3. Please follow the software loader syntax to list and activate the required release.
Python environment
Although we give below the main commands for managing your Python environment from the conda
CLI, the commands using the mamba
CLI are identical, ensuring script portability.
To create an Anaconda environment, you can use the conda create
command, after having loaded the wanted anaconda version as shown above:
% conda create --prefix /<path>/<environment name> python=<version>
The --prefix
option is recommanded to specify a path with write
privileges for the environment and by favouring a shared storage space, because conda environments can be large.
An active environment can be replicate as follow:
% conda env export > environment.yml
This command will export the characteristics of the current environment, create the environment.yml
file, which can later be used to replicate the environment:
% conda create -n <nom nouvel environnement> -f environment.yml
Then you can activate the environment with the conda activate
command:
% conda activate /<path>/<environment name>
To install a package available in the channel <channel>
, you can use the command:
% conda install -c <channel> <package>
Please also consider the tips on custom-installations.
To deactivate the environment, you can use the conda deactivate
command:
% conda deactivate
For more details on managing Python environments, please check the official documentations of conda and mamba.
Anaconda license
In the light of Anaconda terms of service, limiting the number of users without a paid license, it is necessary to avoid the following software channels, which provide packages covered by the license:
pkg/main
pkgs/r
pkg/msys2
To check the software channels used, run the command:
% conda config --show channels
To check the use of packages covered by a paid licenses, run the command:
% conda list --explicit
Recommendations
It is recommended to switch to Miniconda or Micromamba, and configure it via .condarc
for each virtual environment created with the following lines :
channels:
- nodefaults
- conda-forge
channel_priority: strict
Important
The use of conda
as a CLI remains free of charge.