使用Anaconda中的pip命令报错:pip is configured with locations that require TLS/SSL

背景

今天在公司安装了Anaconda,准备更换下Anaconda自带的jupyter notebook的主题,但是执行pip install时报TLS/SSL错误。

安装环境
Win7 64位
Anaconda (Python 3.7),并已将D:\Anaconda3和D:\Anaconda3\Scripts添加到环境变量PATH中。

问题详情
执行以下命令报错:

pip install --upgrade jupyterthemes

错误描述:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting jupyterthemes
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)’: /simple/jupyterthemes/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)’: /simple/jupyterthemes/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)’: /simple/jupyterthemes/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)’: /simple/jupyterthemes/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)’: /simple/jupyterthemes/
Could not fetch URL https://pypi.org/simple/jupyterthemes/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=‘pypi.org’, port=443): Max retries exceeded with url: /simple/jupyterthemes/ (Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)) - skipping
Could not find a version that satisfies the requirement jupyterthemes (from versions: )
No matching distribution found for jupyterthemes

解决方案

最开始在网上搜索同类问题,大都是说python 的ssl模块未安装,从问题描述来看确实也很像,但是他们的问题大多发生在Linux上,而我的是Windows,又联想到Anaconda本来就是一个Python的套件包,包含了许多常用的工具和Python库,不可能犯这种低级错误,所以很可能是环境变量未配置全,导致pip无法找到ssl相关模块。

最终参考之前正常的Anaconda的配置,将"[Anaconda安装目录]\Library\bin"加入PATH后,问题解决。
如下,jupyterthemes安装成功:
pip install 正常更新

猜你喜欢

转载自blog.csdn.net/JerkSpan/article/details/86599690