Search code examples
anacondacondaenvironment

conda create environment not responding


I want to install python 2.7 as a conda environment.

conda create -n python2 python=2.7 anaconda
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment:

it's been running for the last 12 hours.


Solution

  • If all that is actually needed is Python 2.7 environment (not full Anaconda distribution), then see @jakub's answer. However, Conda is perfectly capable of creating an Anaconda distribution environment with Python 2.7, and it should not take 12+ hours to solve.

    Why so long? Channels!

    The extremely long solve is almost certainly aggravated by your channel priorities. An "Anaconda" distribution should source most - if not all - of its software from the anaconda channel (part of defaults channel). However, most users eventually add conda-forge into their global channels and give it higher or equal priority (e.g., channel_priority: flexible). When this is the case, Conda will spend a bunch of time trying to satisfy the packages specified within the anaconda metapackage with the latest versions from conda-forge, and that's what tends to bog things down.

    Option 1: Avoid Mixing Anaconda and Conda Forge

    If you want a faster Anaconda install, then install only from Anaconda

    conda create -n anaconda27 --override-channels -c defaults python=2.7 anaconda
    

    Everything in the anaconda metapackage was originally intended to be sourced from the anaconda channel, so this shouldn't be so unreasonable.

    Note that if you have conda-forge prioritized globally, this will be an issue every time you install in this environment (so remember to override channels).

    Option 2: Mamba

    Another option is Mamba. It's a faster (compiled) drop-in alternative to the conda CLI functionality. It seems to both solve faster and less prone to mutate unrelated packages when requesting changes - but that's just my anecdotal experience.

    # install it in your *base* env (only need this once)
    conda install -n base conda-forge::mamba
    
    # use it like you would `conda`
    mamba create -n python2 python=2.7 anaconda