当“解决环境问题”

无论何时我运行 conda install/remove/update <package>,它都会在告诉我它将要下载/安装/更新的内容列表之前告诉我它正在“解决环境问题”一段时间。可能它正在寻找 <package>的依赖项,但是为什么有时在执行这个操作之后它会执行 拿开包呢?例如,当我试图安装 Mayavi 时,它决定删除 AnacondaNavigator。

此外,它不提供仅执行建议操作的子集的选项。有没有一种方法可以指定我不想删除一个包?

94008 次浏览

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.

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.

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.

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

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.