当anaconda环境下,安装/更新 python包(conda/pip install package)出现如下错误:
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: /bioconda/linux-64/repodata.json (Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”,))’,),)
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: /bioconda/linux-64/repodata.json (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available.",))',),)
此错误,在Ubuntu、windows、mac等都可能出现,很多解决方案归咎为不能访问官网镜像问题,其实有两个问题会报上面错误,所以解决方法也分为两种:
解决方法一:镜像问题
将其设置为国内(清华大学)
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
以上脚本,是修改 ~/.condarc 文件的 channels 配置,因此你也可以直接打开该文件进行设置(上面操作等同于下面两步骤操作):
windows 在 C:\Users\你的电脑名.condarc
channels:
- default
show_channel_urls: flase
修改为:
channels:
- https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
show_channel_urls: true
若需换回默认官网镜像源
$ conda config --remove-key channels
如果需要代理,在 ~/.condarc 加入如下代码
proxy_servers:
http: http://192.168.1.209:3128
https: https://192.168.1.209:3128
注意http:与下一个http:需要空格,首个http:对齐去其他相同,需要两个空格,参考点击 此处;
解决方法二:环境变量问题
如果安装 秒 报开头的错误,那么八成是此问题,而问题一是请求超时,在等待相当一段时间才报错;
参考解决方案
https://github.com/ContinuumIO/anaconda-issues/issues/2760
解决方案描述如下:
%CONDA_HOME% was set to /path/to/Anaconda3
And "%CONDA_HOME%" as well as "%CONDA_HOME%\Scripts" was added before.
To overcome the error, I had to add "%CONDA_HOME%\Library\bin" to path.
Now it works perfectly
解决方案很简单,就是增加几个 anaconda 路径,在系统变量path加入 anaconda 路径 为
D:\anaconda3
D:\anaconda3\Scripts
D:\anaconda3\Library\bin
D:\anaconda3 #为 anaconda 安装路径