conda建新的环境,出现CondaHTTPError: HTTP 000 CONNECTION ......

1年前 ⋅ 1050 阅读

由于之前配置了清华的源,导致直接conda create -n 环境名称 python=3.7报下面的错:

Collecting package metadata (current_repodata.json): failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/win-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.

If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.

'https//repo.anaconda.com/pkgs/main/win-64'

然后在查阅了相关解决办法,发现清华源里面有如下一众文件:

Parent directory/	-	-
linux-32/	-	02 Nov 2020 19:01:46 +0000
linux-64/	-	27 Oct 2022 21:56:33 +0000
linux-aarch64/	-	27 Oct 2022 21:57:47 +0000
linux-armv6l/	-	21 Mar 2020 15:30:06 +0000
linux-armv7l/	-	21 Mar 2020 15:30:08 +0000
linux-ppc64le/	-	27 Oct 2022 21:59:03 +0000
noarch/	-	18 Oct 2022 06:37:37 +0000
osx-32/	-	27 Nov 2017 03:37:37 +0000
osx-64/	-	27 Oct 2022 22:00:09 +0000
osx-arm64/	-	27 Oct 2022 22:01:05 +0000
win-32/	-	24 Jun 2022 17:48:42 +0000
win-64/ -	27 Oct 2022 22:01:56 +0000

意思是找不到相关的文件,别人的修改方法是修改.condarc文件,我在这里附上原文网址,以帮助大家: https://www.cnblogs.com/tianlang25/p/12433025.html
解决办法一:
而我的解决办法是,执行命令:

conda config --remove-key channels

这样就直接清除了清华源,然后使用默认的源创建环境,等环境创建好后,再修改源或者使用源进行安装模块
但是如果你还是想要使用国内的源,怎么办呢?综上,给出了一下解决方案(推荐):
解决办法二:
1.先还是要删除已经有的清华源
2.分别执行下面两个安装源命令即可(其实把原先的源替添加了路劲win-64/和将https修改为http):

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

3.再次执行conda create -n 环境名称 python=3.7就完美解决问题了