目录
背景
报错
网上解决方案
分析
我的解决方案(Linux版)
原因分析
解决步骤
教训
整理不易,欢迎一键三连!!!
送你们一条美丽的--分割线--
操作系统:Linux
conda创建虚拟环境:conda create -n xxx python=3.9报错
[xxx@localhost main]$ conda create -n xxx python=3.9
Solving environment: failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url
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=\'conda.anaconda.org\', port=443): Max retries exceeded with url: /http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64/repodata.json (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available.",))',),)
此时,按照网上各种解决方案修改,添加各种镜像源,都不行。
修改./condarc文件为最原始的状态还不行
其中有一个修改condarc的步骤如下:
#执行命令,添加镜像源
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
#执行命令,将ssl验证置为false,由于镜像源是http,所以必须取消ssl认证
conda config --set ssl_verify false
#最最最重要的一步!!!将默认镜像删除,执行命令
conda config --remove channels defaults
#设置显示镜像url,可有可无,执行命令
conda config --set show_channel_urls true
但是对我的报错没有效果。
因为这个报错是非常快的,刚输入完命令就报错了。所以推断按照这个报错速度,应该不是网络问题,保证网络连接是没有问题的,那就肯定是源不对了,切记,Linux和Windows的各种镜像源地址是不一样的,千万别搞错了。我这个报错就是之前自作主张添加了一堆镜像源。xue的教训啊~
通过vim ~/.condarc 命令编辑condarc文件
我的是之前默认的,没有添加任何源。这一步主要是查看已经添加的镜像源地址。
channels:
- defaults
show_channel_urls: true
default_channels:
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
下次如要安装库,通过pip install xxx -i 镜像源地址的方式自行添加镜像源,不要再魔改condarc文件了。。。
⛵⛵⭐⭐