我已经在我的本地机器上成功安装了Python 3.4和Python 3.6,但无法安装带有pip3的包。

当我执行pip3 install <package>时,我得到以下SSL相关错误:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting <package>
  Could not fetch URL https://pypi.python.org/simple/<package>/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
  Could not find a version that satisfies the requirement <package> (from versions: )
No matching distribution found for <package>

如何修复我的Python3。pip install <package>?


当前回答

在我使用Mac的情况下,我删除了 /应用程序/ Python 3.7。 因为我已经通过brew安装了Python3.7。

但这是信息的一个触发点

pip配置了需要TLS/SSL的位置,但是Python中的SSL模块不可用。

我在这种情况下做了什么

我再次下载了macOS 64位安装程序,并安装。 双击/Applications/Python3.6/Install Certificates.command和/Applications/Python3.6/Update Shell Profile.command。 重启mac 我不确定,但可能有助于成功的是pip.conf。参见pip安装失败。

其他回答

我尝试了很多方法来解决这个问题,但没有一个解决。我现在用的是Windows 10。

唯一有效的方法是:

卸载蟒蛇 卸载Python(我使用的是3.7.3版本) 再次安装Python(记得勾选自动添加到PATH的选项)

然后我用PIP下载了我需要的所有lib…和工作!

不知道为什么,或者这个问题是否与水蟒有关。

I finally solve this issue. These are the detail of my env: Version of Python to install: 3.6.8 OS: Ubuntu 16.04.6 LTS Root access: No Some people suggest to install libssl-dev, but it did not work for me. I follow this link and I fixed it! In short, I download, extract, build, and install OpenSSL (openssl-1.1.1b.tar.gz). Then, I modify .bashrc file follow this link. Next, I download and extract Python-3.6.8.tgz. I edit Modules/Setup.dist to modify SSL path (lines around #211). I did ./configure --prefix=$HOME/opt/python-3.6.8, make and make install. Last, I modify my .bashrc. Notice that I do not include --enable-optimizations in ./configure.

我在windows 10上遇到了同样的问题。我非常具体的问题是由于我安装了Anaconda。我安装了Anaconda,在path /to/Anaconda3/的路径下,出现了python.exe。因此,我根本没有安装python,因为Anaconda包含了python。当使用pip安装包时,我发现同样的错误报告,pip配置了需要TLS/SSL的位置,但是Python中的SSL模块不可用。

解决方案如下:

1)可以在官网重新下载python;

2)进入“Python 3.7 (64-bit).lnk”所在目录

3)导入SSL并退出()

4)键入cmd, "Python 3.7 (64-bit).lnk" -m pip install tensorflow为例。

给,你都准备好了。

降级openssl对我有用,

brew switch openssl 1.0.2s

在macos上,使用下面的命令配置python 3.8.1将解决这个问题,我认为它也适用于Linux。

./configure --enable-optimizations --with-openssl=/usr/local/opt/openssl@1.1/

根据您的系统更改dir参数。