状况介绍

conda最近因为需要安装4.5.0版本的opencv,安装时出现了一堆问题。于是用新创建的虚拟环境做了个测试。下面以opencv4.5.0为例。

注:以下均为我自己尝试的顺序,不一定适合所有人。

常规安装opencv

adocir@adocir:~$ conda install -c conda-forge opencv==4.5.0

第一报错

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.

记住,出现这个后别急着ctrl-c,不一定失败,耐心等着吧。如果到最后依旧没成功直接退出,我做的下一步是更换清华源。
清华大学开源镜像站,照着里面教程走。

第二报错

An unexpected error has occurred. Conda has prepared the above report.

If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers?

[y/N]: n

No report sent. To permanently opt-out, use

conda clean -i之后重启终端。

第三报错

注意,这里的报错和第一报错一模一样,只有在最后

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: \ 
Warning: >10 possible package resolutions (only showing differing packages):
  - https://repo.anaconda.com/pkgs/main/linux-64/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::xz-5.2.5-h7b6447c_0, https://repo.anaconda.com/pkgs/main/noarch/noarch::wheel-0.35.1-pyhd3eb1b0_0
  - defaults/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::xz-5.2.5-h7b6447c_0, https://repo.anaconda.com/pkgs/main/noarch/noarch::wheel-0.35.1-pyhd3eb1b0_0
  - defaults/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::xz-5.2.5-h7b6447c_0, https://repo.anaconda.com/pkgs/main/noarch/noarch::wheel-0.35.1-pyhd3eb1b0_0
  - defaults/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7, defaults/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::xz-5.2.5-h7b6447c_0, https://repo.anaconda.com/pkgs/main/noarch/noarch::wheel-0.35.1-pyhd3eb1b0_0
  - defaults/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0, defaults/linux-64::xz-5.2.5-h7b6447c_0, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7, https://repo.anaconda.com/pkgs/main/noarch/noarch::wheel-0.35.1-pyhd3eb1b0_0
  - defaults/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7, defaults/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0, defaults/linux-64::xz-5.2.5-h7b6447c_0, https://repo.anaconda.com/pkgs/main/noarch/noarch::wheel-0.35.1-pyhd3eb1b0_0
  - defaults/linux-64::xz-5.2.5-h7b6447c_0, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0, https://repo.anaconda.com/pkgs/main/noarch/noarch::wheel-0.35.1-pyhd3eb1b0_0
  - defaults/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7, defaults/linux-64::xz-5.2.5-h7b6447c_0, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0, https://repo.anaconda.com/pkgs/main/noarch/noarch::wheel-0.35.1-pyhd3eb1b0_0
  - defaults/linux-64::xz-5.2.5-h7b6447c_0, defaults/noarch::wheel-0.35.1-pyhd3eb1b0_0, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0
  - defaults/noarch::wheel-0.35.1-pyhd3eb1b0_0, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0, https://repo.anaconda.com/pkgs/main/linux-64/linux-64::xz-5.2.5-h7b6447c_0
  ... and othedone


==> WARNING: A newer version of conda exists. <==
  current version: 4.9.0
  latest version: 4.9.2

Please update conda by running

    $ conda update -n base conda

然后再等一会,它开始下载了。

不适用于我的各路偏方

以下方案我有的尝试过有的不适用,但是暂时记录在这里,每一条完全独立。

  1. 使用了清华源镜像,在~/.condarc中将https://…修改位http://…,如:
channels:
  - defaults
show_channel_urls: true
channel_alias: http://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
channel_priority: flexible                            
  1. 更新conda(警告,upgrade慎用)
adocir@adocir:~$ conda update --all
adocir@adocir:~$ conda upgrade --all
  1. 清理conda(我没用过,仅供参考,如若出现任何问题本人概不负责.jpg)
adocir@adocir:~$ conda clean --all

参考

清华大学开源镜像站.
Conda无法安装或更新的问题.

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐