问题征兆
在内网环境使用anaconda创建新环境:
conda create --name py39 python=3.9
由于网络原因,遇到如下报错:
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffffa9760650>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /anaconda/pkgs/free/linux-aarch64/repodata.json.zstCondaHTTPError: HTTP 000 CONNECTION FAILED for url <http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-aarch64/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.
'http//mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-aarch64'
Platform: linux-aarch64
Collecting package metadata (repodata.json): failedUnavailableInvalidChannel: HTTP 404 NOT FOUND for channel defaults <https://conda.anaconda.org/defaults>The channel is not accessible or is invalid.You will need to adjust your conda configuration to proceed.
Use `conda config --show channels` to view your configuration's current state,
and use `conda config --show-sources` to view config file locations.
解决方法
解决方法是,编辑~/.condarc
,粘贴如下内容。其中channels可以替换成其它源,比如清华源、阿里源。
channel_priority: strict
show_channel_urls: true
ssl_verify: false
proxy_servers:http: http://10.58.235.16:3128https: http://10.58.235.16:3128
channels:- https://repo.continuum.io/pkgs/main/- https://repo.continuum.io/pkgs/free/
注意:
- 设置proxy_servers,指向你的代理服务器,如有必要填上用户名密码,使用http协议。
- 设置
ssl_verify: false
,避免conda做tls校验导致网络连接失败。这个选项是为了搭配代理IP的http协议一起使用。 - 不需要设置channel_alias。
- channels属性里删掉defaults、main等项,只保留第三方源。