解决:An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent......

文章目录

    • 1 问题描述
    • 2 问题解析
    • 3 解决问题
    • 4 参考资料

1 问题描述

在Anaconda下准备下载东西的时候,出现了这样的报错:

Collecting package metadata (current_repodata.json): failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url //conda.anaconda.org/r/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.
ConnectTimeout(MaxRetryError("HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /r/win-64/current_repodata.json (Caused by ConnectTimeoutError(, 'Connection to conda.anaconda.org timed out. (connect timeout=9.15)'))"))

2 问题解析

查找了网上很多资料,可能是源的问题,就是默认下载东西的链接是国外的镜像,存在一些问题,因此将源改成国内的镜像即可。

3 解决问题

① 在cmd下先后执行如下命令:

# 使用清华的镜像链接
conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
# 
conda config --set show_channel_urls yes

② 如果①还是不行,到打开 C盘/用户/(你的用户名xx)/.condarc,我自己的如下图所示:
在这里插入图片描述
解决:An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent......_第1张图片
把以下这段代码复制到这个.condarc文件中:

channels:
  - defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

保存再试一试即可。

4 参考资料

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.

你可能感兴趣的:(那些年踩过的坑)