关于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=‘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 配置,因此你也可以直接打开该文件进行设置(上面操作等同于下面两步骤操作):
windowsC:\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 安装路径
  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值