dkv
dkv

Reputation: 7292

What does conda do when "solving environment"

Whenever I run conda install/remove/update <package>, it tells me it's "Solving environment" for some time before telling me the list of things it's going to download/install/update. Presumably it's looking for dependencies for <package>, but why does it sometimes remove packages after doing this operation? For example, as I was trying to install Mayavi, it decided it needed to remove Anaconda Navigator.

Furthermore it does not provide an option to perform only a subset of the suggested operations. Is there a way to specify that I don't want a package removed?

Upvotes: 82

Views: 129762

Answers (6)

MANOJ MP
MANOJ MP

Reputation: 1

That's because of the version specified for dependencies e.g.: scikit-learn==1.2.2. try to remove the version "==1.2.2", that will install latest version. After that you can uninstall the package and reinstall dependency with specific version using "pip install".

Upvotes: 0

Cornelius Roemer
Cornelius Roemer

Reputation: 7929

The short answer is: use mamba as a drop-in replacement for conda, it's much much faster at solving environments, no more waiting for minutes. mamba has been officially endorsed by the conda team.

Mamba also allows you to configure more precisely which packages you require to be installed and allows you to pin versions, as conda does. For a more detailed comparison of conda and mamba see this Stackoverflow answer: https://stackoverflow.com/a/68043228/7483211

The long answer is: Solving conda environments with more than a few packages that each have dependencies on their own quickly ends up becoming a quite complicated SAT problem (see Boolean satisfiability problem and dependency hell)

With good algorithms, even fairly big SAT problems can be solved fast. In contrast to mamba's solver which is written in C++ and designed to be fast, it seems that conda's solver is not very high performance. It worked well enough when people used small environments in the past, but with bigger and bigger environments, conda has started to struggle.

I made the switch about a year ago and I have not once looked back. The open source project I'm working for (Nextstrain) has also started to recommend mamba in place of conda for new users. I have not seen anyone advocating against using mamba in place of conda.

Upvotes: 11

Stuart Rucker
Stuart Rucker

Reputation: 309

JUST WAIT! I wasted hours trying to fix this. It turns out, it just took around 45 minutes :/

Upvotes: 10

Venkat Govindan
Venkat Govindan

Reputation: 21

conda install --prune <<package>> helped me to install the right channel.

Suspecting environment used are for zipline and channel used not compatible with existing one. prune takes a lot of time but helped me in solving the environment issues.

Upvotes: 2

Katyjean57
Katyjean57

Reputation: 207

As a side note on the "Solving Environment" step...
Lack of administrator privileges may affect whether or where you can install python packages.

I observed that my installs would hang on the "Solving Environment" step and never get through when attempting to install packages while logged in as a non-administrator.

Getting switched to admin was possible for me on the machine I was stuck on, so I just did that and it solved the problem.

Commenter explains workaround when this is not possible.

Upvotes: 9

zhaofeng-shu33
zhaofeng-shu33

Reputation: 776

You can add --debug option to the conda command and see the output from console(or terminal). For example, type conda update --debug numpy. From the output, we can see that the client requests repodata.json from channel list and do some computation locally in the Solving Environment Step.

Upvotes: 60

Related Questions