41

When I type try to run conda update -n base conda, conda hung for around 20-minutes on 'Solving environment' and then returned a package plan that did not include an updated version of conda. The package plan that was returned is provided below.

NOTE: conda update --all solved the environment in a reasonable amount of time (~1 min - I didn't time it precisely).

Steps to Reproduce

conda update -n base conda

As I mentioned above, conda install websocket-client also hung at 'Solving environment' - I already had websocket-client version 0.53.0 installed when I tried to run the install command

Expected Behavior

Conda should either:

  1. If the most recent version is installed, conda should promptly inform the user that an update isn't needed.
  2. If a newer version is available, I'd expect Conda to solve the environment in a shorter period of time. I think that less than 1-2 minutes would be reasonable - 20+ minutes is too long

Originally posted here: https://github.com/conda/conda/issues/7938

Cornelius Roemer
  • 3,772
  • 1
  • 24
  • 55
Jeremy Matt
  • 647
  • 1
  • 7
  • 10
  • 1
    Similar problem. I have a fresh install of Ubuntu 18.04 and updating, installing a new package, or changing the python version takes half an hour or more hanging at "Solving environment:". – Jay Speidell Dec 28 '18 at 03:47
  • Did you ever figure this out? Could it be a permissions issue after reinstalling ubuntu? – Gabriel Fair Jan 08 '19 at 15:20
  • I am having the same problem with fbprophet on a Windows 2016 server with full admin privileges. Other packages seem to install OK. – Ali Jan 10 '19 at 08:50
  • There's been some activity on the github link that I duplicated. Not really a solution, but some ideas of what might be going on. – Jeremy Matt Feb 05 '19 at 10:26

2 Answers2

24

A Common Problem: Suboptimal Channel Prioritization

Anaconda distribution is designed and tested to use the anaconda channel (a subset of defaults) as its primary channel. Adding conda-forge in either a higher- (channel_priority: strict) or equal-priority (channel_priority: flexible) configuration opens up many of the packages to be sourced from Conda Forge instead, and this is where Conda struggles to solve.

Including conda-forge both expands the search as well as opens other packages to be subject to channel switching, and since the anaconda package includes dozens of packages, this can be a huge satisfiability problem to solve. This is often most problematic after the first time conda-forge is added into a user's configuration.

Solutions

There are two high-level ways to improve performance: simplify the solving problem or use a faster solver. Of course, these are not mutually exclusive - feel free to be both thoughtful about what you demand of your solver and adopt optimized tools.

Option 1: Optimize Channel Prioritization

When the anaconda metapackage is installed in an environment, keep the defaults channel at highest priority (first channel in .condarc) and set channel_priority: strict. See the documentation on Managing Channels.

Additionally, one can forcefully prioritize the defaults channel with commands like

conda update -n base --override-channels -c defaults conda

Option 2: Mamba

Mamba is a drop-in replacement for the conda CLI that is faster (compiled) and in my experience tends to be more aggressive in pruning. Once installed, it runs similar to conda, e.g.,

mamba update -n base conda

Note on Alternative Configuration

Many users find the coupling of their environment management infrastructure (Conda) to a large working environment (Anaconda) to be less than ideal. A popular alternative configuration is to maintain a minimal base environment, and if Anaconda is ever needed, to create a new environment with the anaconda package installed.

Alternative options for base environments include

  • Miniconda - minimal base with defaults channel priority
  • Miniforge - minimal base with conda-forge channel priority
  • Mambaforge - Miniforge base + Mamba
merv
  • 67,214
  • 13
  • 180
  • 245
  • 3
    Mamba is a relatively fresh player in this game, but it seems to be very promising. I really recommed anyone who is suffering from slow conda transactions to give option 2 a try! – Christian Herenz Apr 14 '21 at 01:52
  • option 1 works for me. Since I was trying to create a new environment from a requirement files I simply placed **anaconda** before **conda-forge** and it fixed the problem. Thanks. – Carlos Rodrigues Jul 23 '21 at 01:43
  • Option 1 with the suggested command did not work for me. – germ May 03 '22 at 04:11
  • @germ feel free to ping me if you ask a new question with additional details about your situation – merv May 03 '22 at 18:40
  • 2
    Thank you for this. I just blindly switched from miniconda to mambaforge and an install that took 600+ seconds (terminated after that time) completed in 69.7s. – user1556435 Jun 27 '22 at 09:50
-2

Upgrade your conda For particular conda version

conda install conda=4.7.12

For latest conda version

conda update -n base -c defaults conda
sameer_nubia
  • 721
  • 8
  • 8