Search code examples
condaconda-forge

Is it slower to install one package at a time or all at once using conda?


I have just freshly installed the latest Anaconda and need to install 12 packages from conda-forge. Is or should it be slower to install them all at once or one at a time? (The environment solving times are so long that I answering this question myself by trial would take days.)

I first installed Miniconda 3.10 and then created two conda environments 3.9 & 3.7 containing anaconda. I also did:

conda config --set channel_priority strict
conda config --append channels conda-forge

This resulted in "defaults" being listed above "conda-forge" in .condarc, so I did not have to prepend defaults.


Solution

  • Declare all requirements at creation

    Yes, it is absolutely slower to install packages one at a time mostly because the solver has to solve the environment each time.

    For fastest environment setup, declare all requirements at creation time and use mamba (a faster frontend for working with Conda environments). Also, using a YAML to define the environment can help with this.

    Example

    mamba create -n py39 python=3.9 numpy scipy scikit-learn
    

    or with YAML

    py39.yaml

    name: py39
    channels:
      - conda-forge
    dependencies:
      - python=3.9
      - numpy
      - scipy
      - scikit-learn
    
    mamba env create -f py39.yaml
    

    Note on distributions

    If one plans to prioritize Conda Forge (may not apply to OP), then be aware that an Anaconda base is a poor choice. Anaconda is effectively incompatible with that configuration. Miniconda is more compatible, but prioritizing conda-forge effectively converts it to a Miniforge variant.

    For those wanting state-of-the-art performance, I recommend the Mambaforge base distribution. It is preconfigured to prioritize conda-forge channel and includes the mamba front-end.