Linux 系统,conda create 报错:“CondaHTTPError: HTTP 000 CONNECTION FAILED for url ”

Linux 系统,conda create 报错:“CondaHTTPError: HTTP 000 CONNECTION FAILED for url ”

首先,一定要正确的安装 anaconda(任何conda)。

1.问题描述:

Collecting package metadata (current_repodata.json): failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64/current_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.
'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64'’

2.错误原因:默认镜像源访问速度过慢,会导致超时从而导致更新和下载失败。

3.解决方案:更换镜像源为清华镜像源,并且删除默认镜像源。

3.1.首先执行如下几条命令更换清华镜像源

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

恢复为清华的镜像以后,我再次执行创建环境的命令,依旧是不成功。于是尝试打开镜像的地址“https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main”,打开以后看到的是以下界面:

1930873-20200307102004600-1840059319

可以看到....../pkgs/main,这个路径指向不够精确。

进入”C:\Users\Administrator“,打开“.condarc“,你将会看到以下代码:

ssl_verify: true
show_channel_urls: true

channels:
  - httpn://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

将上述代码更改为

ssl_verify: true
show_channel_urls: true

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64

.condarc以点开头,一般表示 conda 应用程序的配置文件,在用户的家目录(windows:C:\\users\\username\\,linux:/home/username/)。但对于.condarc配置文件,是一种可选的(optional)运行期配置文件,其默认情况下是不存在的,但当用户第一次运行 conda config命令时,将会在用户的家目录创建该文件。

3.2.更改镜像源配置文件

在用户根目录(C:Users用户名)下找到.condarc文件,打开并并编辑,删除其中的 -default配置行(这一点非常重要)。

3.3HTTP

如果还不行的话,就要把https 修改成http。

4.重新创建虚拟环境,成功!

[参考文献]

解决Anaconda出现CondaHTTPError HTTP 000 CONNECTION FAILED for url问题

尤其推荐下面(非常推荐)

Anaconda建立新的环境,出现CondaHTTPError: HTTP 000 CONNECTION FAILED for url ...... 解决过程

posted @ 2021-06-09 20:02  AlanChens  阅读(14218)  评论(0编辑  收藏  举报