113

I am running OSX Catalina. After downloading Anaconda, I'm having trouble downloading external packages. I tried in both the GUI and the terminal, but the process keeps getting stuck at "Solving environment".

I understand creating a new environment can be a workaround, but I would rather fix the issue at hand.

Any ideas?

Dominique Fortin
  • 2,212
  • 15
  • 20
Johnson Sam
  • 1,139
  • 2
  • 6
  • 5
  • 2
    conda config --set channel_priority flexible – EEEEH Sep 04 '20 at 03:48
  • 1
    Didn't work for me :/ – Johnson Sam Sep 04 '20 at 04:09
  • 5
    Doesn't look like a downloading problem. Solving occurs locally and scales poorly when trying to install everything in a single monolithic environment (such as Anaconda's **base**). I would recommend that you reconsider creating a new environment. Also, since this is a fresh install, consider Miniconda instead of Anaconda. – merv Sep 04 '20 at 04:15
  • The issue is it is getting stuck at solving when trying to download external python packages like geopandas or pdfminder regardless of how big or small. – Johnson Sam Sep 04 '20 at 04:32
  • 3
    It seems like the issue has to do with conda because I can install packages fine using pip – Johnson Sam Sep 04 '20 at 15:36
  • What command(s) lead to this issue? – AMC Sep 05 '20 at 00:25
  • me too have this issue – dorbodwolf Dec 13 '20 at 13:51

26 Answers26

59

The following steps may work to resolve the issue.

conda config --remove channels conda-forge
conda config --add channels conda-forge

if it doesn't work then try this

conda update conda

if nothing works try seeing this github solution, it worked for many.

Jatin Mehrotra
  • 9,286
  • 4
  • 28
  • 67
  • 1
    Tried both and they didn't work. Do I need to change the file path to a specific path to make these downloads? Currently just at /Users/myname – Johnson Sam Sep 04 '20 at 04:06
  • I just tried that, and it works but the solution for that is basically just creating a new environment, which I feel is more of a workaround that an actual fix. I don't understand why I am facing this issue as my old macbook worked fine without needing to create a new environment – Johnson Sam Sep 04 '20 at 04:31
  • try this `conda config --set channel_priority strict`,did it work? or even this add these paths to my environment variables: C:\Anaconda3 C:\Anaconda3\Library\mingw-w64\bin C:\Anaconda3\Library\usr\bin C:\Anaconda3\Library\bin C:\Anaconda3\Scripts change path according to your directory paths – Jatin Mehrotra Sep 04 '20 at 04:34
  • 3
    I changed the channel priority to strict and to flexible but both still didn't work. I don't understand how to add paths to the environment variables. Also I'm using MacOS – Johnson Sam Sep 04 '20 at 14:05
  • It seems like the issue has to do with conda because I can install packages fine using pip – Johnson Sam Sep 04 '20 at 15:36
  • 3
    _`conda config --remove channels conda-forge`_ Is OP using conda-forge in the first place? – AMC Sep 05 '20 at 00:26
  • 20
    `'conda-forge' is not in the 'channels' key of the config file` – Rubi Shnol Jun 07 '21 at 15:03
44

use this:

conda config --set channel_priority strict

pay attention that it is channel_priority and not priority_channel

  • 16
    In case it helps someone: This solved my "Solving Environment take forever" problem, but I also had to re-order the list of channels in my `environment.yml` file. I put `conda-forge` first, then package-specific channels like `pytorch`, then put `defaults` last. From the docs it seems that this causes conda to skip searching in the low-priory channels once a package is found in a high-priority channel, thus shrinking the search-space, but then the channel order matters very much. – avivr Jan 18 '22 at 09:56
  • This answer reduced the time needed for 'solving environment' for me, after doing ´conda update conda' outside the problematic environment. @avivr's comment also helped to put the channels in the right order. Using something like this ´pytorch::torchaudio´ instead of adding pytorch to the channels list reduced the env creation time (and some conflicts) for me. – KLaz Jul 29 '22 at 12:38
  • 1
    @avir Thank you so much for your helpful comment. It solved my issue. Though I don't understand why setting it to "strict" and having "conda-forge" first is necessary, as many others suggest to simply set the priority ordering to "flexible". How on earth did you find that solution!? :) – CodingButStillAlive Oct 23 '22 at 15:02
  • This alone did nothing for conda version : 22.11.1, conda-build version : 3.22.0, python version : 3.9.13.final. – mccurcio Dec 30 '22 at 15:58
41

running

conda config --set channel_priority flexible

worked for me

Update, still ran into some issues so I found Mamba, and oh my god my life changed conda is the worst package manager ever

all my issues were solved when I used mamba

# install mamba
conda install -n base conda-forge::mamba

# use mamba
mamba install pandas
AbdA
  • 790
  • 7
  • 16
  • Thank you! That fixed the issue for me, on a brand new Python install. – Jared Still Feb 15 '22 at 18:27
  • 19
    I hit this issue trying to install mamba unfortunately :/ – rsmith54 Apr 18 '22 at 12:52
  • 4
    Had to wait over an hour to get Mamba installed (thanks Conda ) - but its speed is life changing! – Nihir May 15 '22 at 14:20
  • 1
    I confirm that installing mamba and then running the commands fixed everything _fast_! – ali14 Aug 27 '22 at 01:07
  • mamba install pointed out the mistake of why the installation took so long (apparently the wrong version of python when creating the environment). After I create a new one with the correct python version, mamba installs it and voila. – Rikudo Pain Dec 29 '22 at 04:27
  • You can use the mamba solver in conda, as explained here: https://stackoverflow.com/a/71759217/7952998 – MDescamps Jun 06 '23 at 15:14
14

Many good comments already - let me try to consolidate and add a few more thoughts:

The main background point is that conda is solving a boolean satisfiability problem https://en.wikipedia.org/wiki/Boolean_satisfiability_problem (colloquially: dependency hell https://en.wikipedia.org/wiki/Dependency_hell).

More details here: https://docs.conda.io/projects/conda/en/4.13.x/dev-guide/deep-dive-solvers.html

In the very early days, with relatively few packages, it was not the end of the world. Now, with many packages each with many versions, conda's non-optimised code can take forever.

  1. mamba is a kind of conda clone rewritten in C, so much much faster. Works like a charm. The recommended way to install it is to download mambaforge, otherwise you can install it from anaconda or miniconda. Read the docs: https://mamba.readthedocs.io/en/latest/
  2. If you cannot install mamba, you can use the mamba solver with conda. details on the Anaconda website: https://www.anaconda.com/blog/conda-is-fast-now
  3. mamba and the libmamba solver do not work behind a corporate proxy with zscaler. This is a bug with zscaler, which sends back packets with "_ransfer-Encoding" instead of "Transfer-Encoding". This throws off mamba but not conda. the bug is documented on github https://github.com/mamba-org/mamba/issues/2197 and https://github.com/mamba-org/mamba/issues/2438
  4. If you have access to mamba on one computer but not another, you can: create an environment with mamba based on a yml file which contains only the packages you need (e.g. pandas); once the environment is created, you can export the yml file, which will contain all the dependencies you hadn't specified (e.g. numpy and pandas) as well as the exact versions of each package. You can then create a new environment on the computer with conda only, based on the more detailed yml file. This way, the slower conda doesn't have to solve that package x is at version 2.3 but only version 1.9 works with package y etc
  5. Solution 4 still requires conda to solve a problem, even if a more limited one. If even that takes forever, you can build the environment with mamba then export a requirements file in the format required by pip, and install all the packages with pip in the slower PC. This is detailed here: https://stackoverflow.com/a/75239980/4045275
  6. In general, try to avoid huge environments with loads of packages you do not need. For the same reason, avoid Anaconda, if you can, and just build the environments you need with miniconda, miniforge or mambaforge. If you have projects of different kind, e.g. a set of datascience projects and one of web-related stuff, maintain two separate environments. Smaller environments with fewer packages means less chance for conflicts and faster solving times for conda.
  7. set channel priority to strict. This means that conda will search channels in the order you specified in your .condarc file, so it won't search the 2nd channel if it found all it needed in the 1st https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-channels.html
  8. For the reason above, if you know most of your packages are available in two channels, put the smaller channel first. This is one of the reasons why, with default settings, miniconda is faster than miniforge: because miniconda searches te conda repository, while miniforge the conda-forge, which is much much larger. But be mindful of the licence terms https://www.anaconda.com/blog/anaconda-commercial-edition-faq whereby commercial users require a licence to access the anaconda repository - but not, if I understand correctly, to access conda-forge

If you know of any other potential solutions or suggestions, do share!

Lastly, I'd add that the newer versions of conda introduced parallel downloading, but, in my experience, the main bottleneck is not the download but solving the environment.

Pythonista anonymous
  • 8,140
  • 20
  • 70
  • 112
10

Please, check that python is actually listed in environment.yml or conda create -n your_environment --file requirements.txt python=3.7. Otherwise, conda is traversing all versions of python available. Check that Python is listed.

andreiliphd
  • 135
  • 1
  • 9
  • This, combined with this other answer: https://stackoverflow.com/a/68019710/3250829 was what solved my problem. I put in the Python version in my environment YAML file instead and the env got built almost immediately. Thanks! – rayryeng Jul 07 '22 at 20:49
7

for updated conda version over 4.12.0 'Libmamba' with advantages like:

  • Improve conda’s resolving speeds by 50-80%*

  • Maximize backwards compatibility so as to not break any current
    functionality

  • Build the plugin infrastructure for others to create custom solvers

are mentioned in Anaconda's official blog post, A Faster Solver for Conda: Libmamba

so for making libmamba your default solver(make sure your conda version is 4.12): conda install -n base conda-libmamba-solver

and to try it temporarily:conda create -n demo --experimental-solver=libmamba --dry-run install <some package>

Farhang Amaji
  • 742
  • 11
  • 24
6

The following works for me.

Spin-off on https://github.com/conda/conda/issues/11919

Instead of waiting (maybe hours) to resolve SAT (A well-known NP-Complete problem) environment, it would be helpful for you to install the faster Conda resolver (https://www.anaconda.com/blog/a-faster-conda-for-a-growing-community). Just so you know, the resolver is not installed by default with Anaconda, so you need to install it manually.

sudo conda update -n base conda

sudo conda install -n base conda-libmamba-solver

conda config --set solver libmamba

Rerun conda install

conda install pytorch torchvision torchaudio pytorch-cuda=11.7 \
 -c pytorch -c nvidia

I hope you find it useful.

Ahmad AlMughrabi
  • 1,612
  • 17
  • 28
3

It might be taking long because of package version conflicts. My solution was to install some packages using pip instead of conda install. For example:

pip install tensorflow

Try this in a new environment so it doesn't mess up your existing ones.

pthomaid
  • 146
  • 2
  • 7
2

conda config --remove channels conda-forge

conda config --set channel_priority flexible

This fixed the problem with the solving environment step. After that I was able to update packages (such as conda and anaconda) and sort out various dependency issues.

PMM
  • 21
  • 3
2

I was having the same issue while creating my conda environment using environment.yml file.

conda env create -f environment.yml

My issue was fixed by updating conda and setting channel priority to strict:

conda update conda
conda config --set channel_priority strict
Fiza
  • 81
  • 1
  • 6
2

I've had this issue running macOS Monterey, with conda taking an age to solve the environment, failing, and causing immense frustration.

My first suggestion would be to install Mamba [1], of which you have two options. If conda does work, but just takes a long time, you can try

conda install mamba -n base -c conda-forge

If conda won't install anything at all, you can try uninstalling anaconda3 using conda install anaconda-clean, then anaconda-clean --yes, then rm -rf anaconda3,rm -rf ~/anaconda3 and rm -rf ~/opt/anaconda3. From there, download the Mambaforge .sh file [1], and run

bash ~/Downloads/Mambaforge-MacOSX-x86_64.sh

Follow the install, and treat mamba exactly how you would treat conda. Then it's simply a matter of selecting your interpreter in your IDE of choice! You'll find that mamba is way faster.

Failing this, you can try using which pip, and then pip install [your package]. I wouldn't advise this one for lots of packages, as you are essentially bypassing the dependancy check, however for small things, it should work fine. Try it, and uninstall it if you get any clashes. Happy fixing!

2

set conda-forge highest priority, remove defaults channel

conda config --add channels bioconda
conda config --add channels conda-forge
conda config --remove channels defaults
conda config --set channel_priority strict

make sure most your package from conda-forge, not defaults. If it doesn't work, try

conda update --all
conda clean -a //use with caution
Fedor
  • 17,146
  • 13
  • 40
  • 131
chris
  • 21
  • 1
1

I had similar problems trying to install external packages such as graph-tools and I solved it by creating a new environment. I know you prefer other options but it's the only thing that worked for me.

Pablo
  • 87
  • 5
1

Sounds very simple but make sure you're in your environment

conda activate <Your Environment>
GILO
  • 2,444
  • 21
  • 47
1

After some reading I found out the .condarc file is not created by default (is stated by the official Anaconda documentation. So what I did is delete de .condarc file and then used the following command

conda config --set channel_priority flexible

And then it got unstuck

Then I tried conda update conda just to test it, and everything worked again.

el_xino
  • 11
  • 3
0

you may also want to check your ~/.conda directory permissions. I installed conda on my MacOS using Homebrew and for some reason this directory had only read/write permissions for root. After changing the permissions and following the instructions from above, everything works smooth and fast now

Erich Eichinger
  • 1,898
  • 17
  • 15
0

upgrading conda base package has fixed it. ref : https://docs.conda.io/projects/conda/en/latest/user-guide/install/rpm-debian.html

Vadiraj k.s
  • 55
  • 1
  • 8
0

i had the same problem when i tried to install packages for my env i tried the conda env update -f environment.yml even doesn't worked (in yml file i have name: tf2 that i point to update my env still doesnt upgraded) but now which i tried this it worked :d

conda activate tf2
conda env update -n tf2 -f environment.yml --prune

tzelal
  • 11
  • 4
0

For other weary travelers: if you find conda taking hours to solve an environment, try install packages one at a time. Works like a miracle.

John Johnson
  • 140
  • 10
0

Another solution that may not have been mentioned is that the dependencies that you may want to install within your conda env are already installed. Using conda-list within your env you may confirm.

With a package such as tethys platform they did not mentioned this and i was left wondering why my conda install process kept getting stuck at the solving stage. Late into the night bingo checked into my env and sure enough the dependencies where already installed. Now can progress to my next phase.

0

I faced the same issue for tensorflow and solved it by doing the next:

  • create new environment conda create -n tf tensorflow
  • moved to the new environemnt conda activate tf
  • downloaded my package there.

it worked and solved the issue, I think this happened due to not completing a previous install and got stuck in the middle.

a0m0rajab
  • 115
  • 7
0

In my case, I tried using the Visual Studio code terminal to create a new environment and install python version 3.6 with the following command,

conda create -n env_name python=3.6

But it hangs in the solving environment section.

The solution was to go to the anaconda prompt(run as admin),

first, deactivate base env

conda deactivate

create new env

conda create -n env_name 

activate your new environment

conda activate env_name

Then do whatever you want in the env(in my case, I installed a specific version of python)

conda install python=3.6
0

cannot provide a solution but I have to say that it's not "stuck"

It's just sooooo slow.

Examining conflict for _anaconda_depends anaconda _ipyw_jlab_nb_ext_conf:  51%|███████████████████████▎                      | 33/65 [14:53:43<14:00:25, 1575.79s/i| 

Sometimes it looks like to be stuck because the prompt is not changing, but actually it's because the limited width of console is intercepting the prompt. Conda do have a progress bar and an estimated finish time.


Well yes, the time is deadly long, as long as several days on my old i5-8300H...but if you leave it alone and keep waiting it'll finally work.


20230509 update: Finally it's over after ~48h of running. This is a part of what it'll finally print out.

Package backports.functools_lru_cache conflicts for:
backports.functools_lru_cache
anaconda -> astroid==1.6.5=py27_0 -> backports.functools_lru_cache
conda-build -> conda-verify -> backports.functools_lru_cache
conda-verify -> backports.functools_lru_cache
_anaconda_depends -> backports.functools_lru_cache
prompt-toolkit -> wcwidth -> backports.functools_lru_cache
wcwidth -> backports.functools_lru_cache
spyder -> pylint[version='>=1.0'] -> backports.functools_lru_cache
anaconda -> backports.functools_lru_cache[version='1.4|1.5|1.5|1.6.4',build='py27h9586e20_1|py27_1|py_2|pyhd3eb1b0_0']

Package six conflicts for:
prompt-toolkit -> six[version='>=1.9.0']
conda-verify -> six
anaconda-navigator -> anaconda-client[version='>=1.6.14'] -> six
conda[version='>=4.13.0'] -> conda-package-handling[version='>=1.3.0'] -> six[version='>=1.5.2']
matplotlib-inline -> traitlets -> six
importlib_metadata -> pathlib2 -> six
pip -> html5lib -> six[version='>=1.9']
conda-build -> six
ipython -> prompt-toolkit[version='>3.0.1,<3.1.0'] -> six[version='>=1.9.0']
zipp -> more-itertools -> six[version='>=1.0.0,<2.0.0']
traitlets -> six
anaconda -> asttokens==2.0.5=pyhd3eb1b0_0 -> six[version='>=1.0.0,<2.0.0|>=1.10|>=1.4.1|>=1.5|>=1.9.0|>=1.6.0|>=1.5.2|>=1.15.0|>=1.13.0|>=1.12.0|>=1.4.0|>=1.9|>=1.11.0|>=1.12,<2|>=1.7.3|>=1.10.0|>=1.4']
pickleshare -> pathlib2 -> six
python-dateutil -> six[version='>=1.5']
ipykernel -> packaging -> six

Since it's gonna be reaaaally long, it would almost 100% take all of your console buffer. If you want to analyze the result be sure to redirect it into a file in advance.

Lightyears
  • 1,260
  • 1
  • 4
  • 5
-3

Choose one:

  • Start fresh with a new Anaconda installation. Pay attention during installation to make sure that your install path is a subfolder of your home folder, such as /Users/me/anaconda3
  • Start fresh using the .sh installer instead of the .pkg installer. This installer makes it simpler to choose the destination path, and gives you more choice on how you want your shell to behave.

check out the link for more details

This is another answer for environment failure, but for windows OS

pooza
  • 30
  • 5
-3

Try installing ANACONDA3 2019-3. I had similar issues but after installing the above version of anaconda they were all fixed.

-3

This fixed the hang for me. Although the install went on to fail. conda config --set priority_channel strict

SpaceElmo
  • 1
  • 1