conda如何使用清华源

发布时间:2022-02-25 15:00:27 作者:小新
来源:亿速云 阅读:1039

这篇文章给大家分享的是有关conda如何使用清华源的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

前言

在下载OpenCV的时候发现清华的conda channel镜像已经不能用了,故在此记录:
1)如何显示所有channel;
2)如何更换channel。

1 显示所有channel

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

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

(base) C:Usersdehen>conda config --show channels
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - 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 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
这个命令是为了移除之前conda config --show channels显示的清华源。

(base) C:Usersdehen>conda config --remove channels  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

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

(base) C:Usersdehen>

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

3 添加可用的清华源

参考[4],我发现自己之前安装的清华源的地址https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ 是清华维护的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如何使用清华源”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

推荐阅读:
  1. Conda的安装和配置
  2. python关于conda创建新环境

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

conda

上一篇:html5中如何对span进行宽度设置

下一篇:springboot是如何集成kafka

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》