我已经在我的本地机器上成功安装了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>?


当前回答

我在OSX 10.11上遇到了类似的问题,因为在3.6之上安装了python 3.7的memcached。

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

花了几个小时解链接openssl,重新安装,改变路径。但一切都无济于事。将openssl版本从旧版本更改为旧版本,做到了这一点:

brew switch openssl 1.0.2e

我在网上没有看到这个建议。希望它能为某人服务。

其他回答

特穆克斯

这是因为我没有安装现有的openssl版本。

pkg install openssl-tool

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

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

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

python文档实际上非常清楚,按照说明做了工作,而我在这里找到的其他答案并没有解决这个问题。

首先,安装python 3.x。例如3.6.2版本https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz 通过运行brew install openssl,确保已经安装了openssl tar xvzf python -3.6.2.tar。xz && cd Python-3.6.2 然后如果python版本< 3.7,则运行

CPPFLAGS="-I$(brew -prefix openssl)/include" \ LDFLAGS="-L$(brew -prefix openssl)/lib" \ . / configure——with-pydebug 5. 最后,运行make -s -j2 (-s是沉默标志,-j2告诉您的机器使用2个作业)

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.

在我使用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安装失败。