Conda install some-package 挂起(解决环境:失败)

2022-01-10 00:00:00 python conda geopandas anaconda

问题描述

我尝试了多种方法,但无法 conda 安装软件包(在我的例子中是 geopandas).我尝试了 geopandas 安装指南,但得到了求解器永远运行的输出.在创建新环境后,我尝试不创建环境,使用 defaults 频道并使用 conda-forge 频道.没有任何效果.

I have tried multiple ways but can't conda install packages (in my case, geopandas). I tried geopandas install guide, but get output that the solver runs forever. I tried without creating an environment, after creating a new environment, using defaults channel and using conda-forge channel. None worked.

$ conda create -n top 
$ conda activate top
$ conda config --env --add channels conda-forge
$ conda config --env --set channel_priority strict
$ conda install python=3 geopandas

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment:  

我不想使用 pip install,因为我更喜欢使用 conda install.我还尝试按照 this answer 使用 Anaconda Navigator 进行安装,但进度条保持不变运行说解决包规范.

I don't want to use pip install because it is preferred to use conda install. Also I tried installing using Anaconda Navigator following this answer, but the progress bar keeps running saying solving package specifications.


解决方案

支持在创建时指定约束

迭代安装包是 Conda 的真正瓶颈.如果您事先知道 env 需要某些包,请在创建时指定它们:

Favor Specifying Constraints at Creation

Iteratively installing packages is a real choking point for Conda. If you know up front that the env will require certain packages, then specify them at creation:

conda create -n top -c conda-forge -c defaults python=3 geopandas

这对我来说在几秒钟内就解决了.如果你有很多包,那么 使用 YAML.

This solves in seconds for me. If you have many packages, then use a YAML.

有时临时安装是不可避免的.对于棘手的解决方案(或一般情况下),尝试使用 mamba, conda 的已编译(快速!)替代品.曼巴将在康达挣扎的地方大放异彩.

Sometimes ad hoc installations are unavoidable. For tough solves (or just generally), try using mamba, a compiled (fast!) drop-in replacement for conda. Mamba will shine where Conda struggles.

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

# use mamba
mamba install -n top geopandas

相关文章