conda
conda is a package manager used to manage dependencies for python projects (with some functionality for R and some other programs). You can export your environment for your Git repository.
We recommend that you use conda whenever possible to facilitate reproducibility and reduce package conflicts. If you need to use packages that are not available within conda, try to maintain a similar level of documentation: what packages did you use, and what versions?
Make a separate environment for each project, and commit its environment.yml to the project repository. An environment file that lists only the packages you asked for is easy to read, but it doesn’t fix the versions of their dependencies, so for a paper, also export a fully resolved file that records the exact versions used to produce the results. See Data Management and Open and Reproducible Research.
Installation
conda installation procedures vary slightly depending on your operating system. We recommend installing Miniforge and adding packages as you need them.
Miniforge is a minimal installer that defaults to the community-run conda-forge channel. We prefer it to Miniconda or the full Anaconda distribution for two reasons:
- The full Anaconda installation bundles a lot of packages you will not use.
- Anaconda Inc.’s terms of service for its
defaultschannels require a paid license for some institutional use. Miniforge doesn’t use those channels, so the license question doesn’t arise. If you have an existing Miniconda or Anaconda installation that uses thedefaultschannel, consider switching.
Miniforge also includes mamba, a faster replacement for the conda command that takes the same arguments. Recent versions of conda use the same solver, so the difference is smaller than it was, but mamba install is still generally quicker.
Usage
The conda documentation has a current cheat sheet of common commands.
If you installed Miniforge, conda-forge is already your default channel and there is nothing to configure. On an older Miniconda or Anaconda installation, add conda-forge and make its priority strict:
conda config --add channels conda-forge
conda config --set channel_priority strict
Mixing channels is a common cause of environments that conda can’t solve, so use one channel per environment.
The conda documentation has more information on managing channels.