关于anaconda环境conda/pip install 报SSL错误问题(有两种情况)
当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=’http://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 @xsx 评论提到,若仍出现SSLError,https替换http;替换前移除此前加入的镜像源(重置):conda config –remove-key channels
打开 ~/.condarc 文件,将
channels: – defaultshow_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://127.0.0.1:9001 https: https://127.0.0.1:9001注意 http: 与下一个 http: 需要空格,首个 http: 对齐去其他相同,需要两个空格,参考点击 此处;
解决方法二:环境变量问题
如果安装 秒报开头的错误,那么很可能是此问题,而 问题一 是请求超时,在等待相当一段时间才报错;
参考解决方案
解决方案描述如下:
%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%Librarybin” to path.
Now it works perfectly
解决方案很简单,就是增加几个 anaconda路径,在系统变量path加入 anaconda路径 为
D:anaconda3D:anaconda3ScriptsD:anaconda3LibrarybinD:anaconda3 为 anaconda 安装路径