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

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

当前回答

对于OpenSUSE,以同样的方式,但对上面列出的包做了一些更改:

zypper install zlib-devel libopenssl-devel ncurses-devel sqlite3-devel readline-devel tk-devel gdbm-devel libpcap-devel xz-devel

然后cd到Python源代码dir和

make
make install

or

make
make altinstall

也许

ln -s /usr/local/lib64/python3.6/lib-dynload/ /usr/local/lib/python3.6/lib-dynload

应该为OpenSUSE用户执行。请参见Python 3.7安装无法在openSUSE Leap 42.3上工作

其他回答

Windows 10, Windows 7 如果pip install在CMD提示符下不工作,使用Anaconda提示符运行它-它工作。

https://github.com/pypa/virtualenv/issues/1139

对于未来试图解决这个问题的Oracle Linux用户,下面是对我有用的方法。 首先安装缺少的库:

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel 
readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

然后cd到Python3。X库并运行:

make
make install 

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

我在Visual Studio Code从VS Code提示安装pylint时遇到了这个问题。 通过打开Anaconda安装目录并运行,我能够克服这个问题

pip install pylint

然后VS Code很高兴,但这并没有解决运行时的问题

& C:/Users/happy/Anaconda3/python.exe -m pip install -U pylint

基本上都给出了相同的错误,所以看起来VS Code无法访问python模块。

注意,VS Code在安装时选择了它看到的第一个python env,屏幕的左下角表示正在使用哪个env。单击该区域可以设置环境。所以即使你在一个环境中运行pip安装,VS Code也可能会看到一个不同的环境。

最好的方法是确保VS代码选择了正确的python环境,并且相同的环境在系统路径中(在系统属性->高级->环境变量下)

在Path变量下,编辑并浏览到你想要VSCode使用并添加到Path的特定Anaconda目录,我需要添加以下内容:

C:\Users\happy\Anaconda3\
C:\Users\happy\Anaconda3\Scripts\
C:\Users\happy\Anaconda3\Library\bin\
C:\Users\happy\Anaconda3\Library\mingw-w64\bin\

您的Anaconda安装目录可能不同。 需要注意的是,Windows直到重新启动终端才使PATH变量生效。在这种情况下,关闭并重新操作VS代码。如果使用终端或PS Shell,则关闭并重新打开并检查路径,以确保它包括在内。

我得到了同样的错误:

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