前言
今天给学弟在anaconda上搭建一个pytorch的gpu运行虚拟环境,在创建环境的时候报SSLError的错误(如图)
解决方案
现有博客大多数是直接通过更改镜像来解决问题,但更改为阿里的镜像后依然报同样的错误(只是报错的url变了),还有一种方法是把现有的镜像删除,恢复原镜像,但是也报错了
Collecting package metadata (current_repodata.json): failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/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.
SSLError(MaxRetryError('HTTPSConnectionPool(host=\'mirrors.tuna.tsinghua.edu.cn\', port=443): Max retries exceeded with url: /anaconda/pkgs/free/win-64/current_repodata.json (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))'))
# 更换清华源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
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
#删除原来的镜像
conda config --remove-key channels
然后找到.condarc文件(目录:“C:\Users\Red-scarf.condarc”),直接替换里面的镜像,并设置ssl_vertify为false,问题解决。
channels:
- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
- https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
show_channel_urls: true
# 重点是这个false
ssl_verify: false
有些马友的目录下可能没有.condarc文件,创建condarc文件命令:
conda config --add channels r
什么是ssl?
https和ssl分别是什么?有什么关系?