Conda's solving environment takes forever
Asked Answered
L

3

8

I am using conda since one year, since several weeks, whenever I want to install a package using conda install -c anaconda <package_name>, for any package, it is just stuck at the Solving environment step.

I just want to install, for example, sympy or mpmath for Python...

Is there some magic command to solve this problem ?

Thanks and regards

Levkas answered 24/6, 2022 at 11:57 Comment(2)
I'd argue the magic command is mamba. You still have to get that installed into base, which still may have the initial solving issue. https://mcmap.net/q/377704/-conda-takes-20-minutes-to-solve-environment-when-package-is-already-installedSaccharine
Does this answer your question? Stuck at Solving Environment on AnacondaHospitaler
S
16

Use pip instead of conda.

Nowadays, Conda is pretty much broken because its native algorithm does not scale with the number of packages in real-world applications. Its developers are stubborn and reluctant to change and adapt, turning the toolkit more and more useless and hopeless.

FYI, both pip and conda are Python package managers (developed by different groups of people).

For common Python package installation such as sympy and mpmath, you can

  1. either use Python pip installation:
~/anaconda3/bin/python -m pip install sympy mpmath

(if your anaconda3 is installed in your home folder, at ~/anaconda3; this command will install Python packages into any folder that your anaconda3 is currently located at (or installed at), e.g., if your anaconda3 is installed at /anaconda3 but moved to /opt/anaconda3, then running /opt/anaconda3/bin/python -m pip install sympy mpmath will install anaconda3 into /opt/anaconda3; you can run /opt/anaconda3/pip install sympy mpmath if your anaconda3 is originally installed at /opt/anaconda3 and not relocated) to install the packages into anaconda3's folder, i.e., ~/anaconda3/lib/python3.*/site-packages/

  1. or Linux native installation (e.g. for Ubuntu/Debian-based-Linux):
apt-get install python3-sympy python3-mpmath

to install the packages into the system folder, i.e., /usr/lib/python3/dist-packages/

  1. If you use Python conda installation:
~/anaconda3/bin/python -m conda install sympy mpmath

you often need to wait for hours and might end up with failure or even a corrupted anaconda installation (which I have encountered once in a while and then have to re-install anaconda3 completely).

Some notes to conda developers:

  • by default, you should not perform a full check on the integrity of all installed packages, just keep an index file listing each package's installation state
  • add an option to perform full integrity check on all packages. Since your full integrity check is on per-file level, maybe it can find and solve some conflicts that pip cannot do.
Saberhagen answered 7/11, 2022 at 2:45 Comment(0)
J
11

A better answer for 2023: keep using conda, but just use the libmamba solver.

Conda is actually making this the default going forward, and things should be much faster.

Blog post: https://conda.org/blog/2023-07-05-conda-libmamba-solver-rollout/ Additional info: https://www.anaconda.com/blog/a-faster-conda-for-a-growing-community

To switch to the new solver, first do

conda update -n base conda

and then

conda install -n base conda-libmamba-solver
conda config --set solver libmamba
Jenson answered 12/9, 2023 at 15:51 Comment(3)
Oddly, I still had to set the solver on conda 23.9.0 despite their documentation claiming mamba was the default. Perhaps it's because I upgraded instead of fresh installed.Slesvig
@Slesvig default to conda-libmamba-solver starts with 23.10 (see Release Notes).Saccharine
Tried to install conda-libmamba-solver, stuck solving environment againNorfolk
C
0

The bottom line to the process that worked for me was to use conda-libmamba-solver updating conda in stages from 23.9.0 --> 23.11.0 --> 24.3.0, rather than repeatedly trying and failing to update from 23.9.0 directly to 24.3.0. using just conda. I ran it as admin in the Anaconda PS prompt.

Cavallaro answered 22/4 at 4:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.