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 only lists direct dependencies is readable but does not pin transitive ones; for a paper, export a fully resolved file as well so the exact versions used to produce the results are recorded. 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 needed.
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 default channels require a paid license for some institutional use. Miniforge avoids the question entirely by not using those channels. If you have an existing Miniconda or Anaconda install pointed at the
defaultschannel, it is worth switching.
Miniforge also ships mamba, a much faster drop-in replacement for the conda command. Modern conda has adopted the same solver and the gap has narrowed, 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. If you are on an older Miniconda or Anaconda install, point it at conda-forge and make that priority strict:
conda config --add channels conda-forge
conda config --set channel_priority strict
Mixing channels is the most common cause of unsolvable environments, so pick one and stay there.
The conda documentation has more information on managing channels.