conda channel的镜像设置


————————————————
版权声明:本文为CSDN博主「宇内虹游」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_39278265/article/details/84782550

前言

1)如何显示所有channel;
2)如何更换channel。

1 显示所有channel

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

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

(base) C:\Users\dehen>conda config --show channels
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - defaults

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

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

(base) C:\Users\dehen>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:\Users\dehen>conda config --remove channels  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

(base) C:\Users\dehen>conda config --show channels
channels:
  - defaults

(base) C:\Users\dehen>

这时候再运行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 <包名> 更新指定包

参考文献

[1] Annaconda 增加删除镜像 channel, 以及其他python包安装解决办法 https://blog.csdn.net/mtj66/article/details/57074986

最开始是看到这里的评论,发现清华的源用不了。
[2] conda常用命令详解 https://www.jianshu.com/p/484cfbf45ed3

在这里学到了一些conda的命令
[3] [加速]为conda添加国内镜像 https://www.aliyun.com/jiaocheng/459144.html

在这里发现原来我之前添加的清华源,和真正的清华源不一样,这促使我进一步寻找可用的清华源。
[4] Anaconda 镜像使用帮助 https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

这里是清华源的官网,我找到了可用的清华源并进行了安装。

相关推荐

  1. conda channel镜像设置

    2023-12-18 09:22:01       48 阅读
  2. node设置镜像

    2023-12-18 09:22:01       61 阅读
  3. 设置NPM镜像命令

    2023-12-18 09:22:01       33 阅读
  4. npm 设置镜像

    2023-12-18 09:22:01       23 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-18 09:22:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-18 09:22:01       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-18 09:22:01       82 阅读
  4. Python语言-面向对象

    2023-12-18 09:22:01       91 阅读

热门阅读

  1. 力扣面试150题 | 15.三数之和

    2023-12-18 09:22:01       55 阅读
  2. Spring-整合MyBatis

    2023-12-18 09:22:01       55 阅读
  3. Cmake基础(6)

    2023-12-18 09:22:01       52 阅读
  4. Kubernetes 容器编排(3)

    2023-12-18 09:22:01       42 阅读
  5. python 读取execl 日期是数字或者字符串的处理

    2023-12-18 09:22:01       65 阅读
  6. 【机器学习】数据降维

    2023-12-18 09:22:01       69 阅读
  7. 机器学习scikit-learn实现

    2023-12-18 09:22:01       53 阅读
  8. xgboost机器学习算法通俗理解

    2023-12-18 09:22:01       52 阅读
  9. 使用AppleScript自动滚动预览

    2023-12-18 09:22:01       57 阅读
  10. 82. Remove Duplicates from Sorted List II

    2023-12-18 09:22:01       71 阅读
  11. 开源攻防武器项目

    2023-12-18 09:22:01       40 阅读