conda环境安装包报错:The following packages are not available from current channels

解决方法:添加channel来源,比如清华的conda镜像站

1 显示所有channel

首先,conda config --show能够显示出所有conda的config信息。

如果我们只想看channels的信息,输入conda config --show channels即可,如下:

(base) C:Usersdehen>conda config --show channels
channels:
  - Error
  - defaults

现在我们有两个源,一个清华镜像,一个defauls默认下载源。

然而这个清华源已经不能用了,我在下载opencv的时候,输入:conda install opencv,但是报错:

(base) C:Usersdehen>conda install opencv
Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64/repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
ConnectionError(ReadTimeoutError("HTTPSConnectionPool(host='mirrors.tuna.tsinghua.edu.cn', port=443): Read timed out."))

所以我打算删除这个源。

2 移除清华镜像

输入:conda config --remove channels Error
这个命令是为了移除之前conda config --show channels显示的清华源。

(base) C:Usersdehen>conda config --remove channels  Error

(base) C:Usersdehen>conda config --show channels
channels:
  - defaults

(base) C:Usersdehen>

这时候再运行conda config --show channels会发现清华源已经被删除了

3 添加可用的清华源

参考[4],我发现自己之前安装的清华源的地址Error 是清华维护的conda三方源之一conda-forge的镜像,,,此外清华还有很多可用的源。

所以我根据官网指示进行了添加:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

conda config --set show_channel_urls yes的意思是从channel中安装包时显示channel的url,这样就可以知道包的安装来源了。

4 下载opencv

在添加好这个源(channel)之后,我重新运行conda install opencv,果然能够成功下载!!!

但是中间竟然是自动安装,在安装前的确认[Y/N]的时候,conda直接跳过了,默认是Y。。。

这让我非常难受,所以我运行了:

conda config --set always_yes false

(这里的意思是安装确认中,不默认yes,而是由我来决定)

5 一些其他的conda指令

conda install <包名> 安装指定包
conda remove <包名> 移除指定包
conda update <包名> 更新指定包

转载自:conda怎么使用清华源?设置channel镜像详解 | w3c笔记 (w3cschool.cn)

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值