解决方法集合CondaHTTPError:HTTP 000 CONNECTION FAILED for url<https://mirrors.tuna.tsinghua.edu.cn/anaco

目录

背景

解决方案

主要原因:配置没配对

方法A:在cmd输入

方法B:修改.condarc(运行期配置文件)​​​​​​

其他原因

原因A:开了代理或者VPN

原因B:没有关防火墙等安全管家

原因C:镜像地址无法访问

原因D:镜像源加上系统

原因E:内网连接的服务器不能访问外网

conda config相关指令格式

查看conda config

添加channel

删除channel

删除default

tips:pip镜像源下载包

暂时设置镜像源

永久设置镜像源下载


背景

因为默认源下载速度较慢,所以更换镜像源。

以清华源为例Index of /anaconda/pkgs/main/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

解决方案

主要原因:配置没配对

方法A:在cmd输入

(删除 ”- default“(可选))
conda config --remove channels defaults
(添加镜像源,注意是http,而非https,因为https有时候会出现连接错误的问题,改成http后不会再出现此类问题。)
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
(在设置中显示以上镜像源)
conda config --set show_channel_urls yes
(关掉验证,对于http来说,走的是明文传输,不加密的,就不需要验证,其中信息的加密方式为SSL)
conda config --set ssl_verify false

如果不成功可以试试方法B

方法B:修改.condarc(运行期配置文件)​​​​​​

也可以直接在.condarc文件中改ssl_verify ;

如果.condarc文件找不到的话,是因为没有在cmd命令中输入 conda config命令,只有第一次输入该命令之后,系统才会自动创建.condarc文件。

show_channel_urls: true
default_channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - 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
ssl_verify: false

其他原因

原因A:开了代理或者VPN

原因B:没有关防火墙等安全管家

原因C:镜像地址无法访问

  • 测试:

a.网站直接打开镜像地址,发现进不去,则说明是原因C

b.执行“conda config --remove-key channels”命令,恢复源为默认。

再次执行下载。若发现除了镜像地址不一样以外,其他的描述是一样的,则说明不是原因C

  • 解决:

国内镜像源
阿里云 http://mirrors.aliyun.com/pypi/simple/
豆瓣http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
华中科技大学http://pypi.hustunique.com/

例如:更换清华源为中科大源

https://mirrors.ustc.edu.cn/anaconda/pkgs/free/

https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
通过conda install cython 命令 下载

原因D:镜像源加上系统

原因E:内网连接的服务器不能访问外网

(此处的外网:根据服务器的定义)

可从把安装包下载下来,上传服务器﹐做成本地源使用

conda config相关指令格式

查看conda config

conda config --show


添加channel

conda config --append channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/


删除channel

conda config --remove channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/


删除default

conda config --remove channels defaults
 

tips:pip镜像源下载包

暂时设置镜像源

pip install 要安装的包 https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python

pip install opencv-python https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python

永久设置镜像源下载

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple


参考链接:解决CondaHTTPError:HTTP 000 CONNECTION FAILED for url<https://mirrors.tuna.tsinghua.edu.cn/anaconda***_洲的学习笔记的博客-CSDN博客

猜你喜欢

转载自blog.csdn.net/qq_28838891/article/details/128150325