我使用的是Python 3.6。当我尝试使用pip3安装“模块”时,我遇到了这个问题:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available

当前回答

为我工作。

pkg install openssl

使用此选项可以启用ssl。

其他回答

我在使用Ubuntu、pyenv和pyenv管理的Python 3.8.1时遇到了这个问题。实际上没有办法让pip正确工作,因为每次我试图安装任何东西,包括pip本身,都会出现相同的错误。 最终的解决方案是通过pyenv安装一个更新的版本,在本例中是3.8.6。显然,从3.8.4开始,Python已经准备好开箱运行SSL/TLS,所以一切都很好。

我得到了同样的错误:

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: 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/pb-tool/
WARNING: 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/pb-tool/
ERROR: Operation cancelled by user
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

在《Anaconda》中,我使用了以下命令:

conda install anaconda-navigator

本文中提到:pip配置了需要TLS/SSL的位置,但是Python中的SSL模块不可用

对于Windows 10下的Miniconda3, python=3.7.5,我尝试了以上所有建议;毫无效果。我不得不降级到python=3.7.0,这解决了这个问题

conda install python=3.7.0

显然这很混乱。答案表明升级到3.8.5也可以工作,但这在我的环境中有太多的副作用。

此问题是由于您的PC上缺少OpenSSL包。

如果pip install openpyxl也给出错误。

你可以通过以下站点安装OpenSSL(Win64 OpenSSL v1.1.1g)来解决这个问题:

slproweb.com/products/Win32OpenSSL.html

重新启动您正在使用的IDE,使更改生效。

如果您已经通过scoop安装了anaconda,并且在conda环境中使用pip时遇到此错误,您可以通过…

将这些添加到路径中

C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current\Scripts
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current\Library
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current\Library\bin

通过scoop安装openssl

scoop install openssl

并从..复制以下dll。\anaconda3\Library\bin到..\anaconda3\ dll

引用:

https://stackoverflow.com/a/54897379 https://stackoverflow.com/a/60405693