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

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

当前回答

只要尝试通过Anaconda提示安装即可

其他回答

如果您已经通过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

操作系统一样,pyenv

如果你的python是pyenv安装的,其中pyenv是在macOS上安装的,可能有一个更新的版本可以修复这个问题:

$ brew update && brew upgrade pyenv

然后重新安装python版本:

$ pyenv install 3.7.2
pyenv: /Users/luckydonald/.pyenv/versions/3.7.2 already exists
continue with installation? (y/N) 

注意,像这样覆盖现有的python安装有点脏,但在我的例子中,它确实有效。可能更干净的方法是删除它,然后正确地重新创建。

问题可能来自您安装的openssl包版本。这就是我的情况,我解决了这个问题,只是升级它。我在Mac OS上,使用brew:

brew upgrade openssl

如果你用brew安装了python,这应该会直接修复这个问题,因为python依赖于openssl

如果有人使用Arch Linux操作系统,我通过运行这个解决了TLS/SSL问题:

sudo pacman -S openssl

然后我可以使用pip来安装我需要的包:

pip install openpyxl

我得到了同样的错误:

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模块不可用