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


当前回答

特穆克斯

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

pkg install openssl-tool

其他回答

从源代码构建是我在Ubuntu 22.10上的工作方式:

手动安装OpenSSL,在这里用OpenSSL 1.1.1测试,提取然后运行:

./config --prefix='/opt/openssl' --openssldir='/opt/ssl'
make
make install

然后使用旧版本的Python 3(这里是Python-3.8.16)运行:

export LD_RUN_PATH='/opt/openssl/lib'
export CC='gcc-12'  # sudo apt install gcc-12
./configure --enable-optimizations \
            --with-openssl='/opt/openssl' \
            --prefix='/opt/python/3.8' -C
make
make install

测试:

/opt/python/3.8/bin/python3 -c 'import ssl; print(ssl.OPENSSL_VERSION)'
OpenSSL 1.1.1s  1 Nov 2022

前两天我也遇到了同样的问题,直到现在才解决。

我尝试使用digicert_high_asance_ev_root_ca的——trust-host选项。pem不工作,我无法安装ssl模块(它告诉它不能安装python版本大于2.6),设置$PIP_CERT变量也没有修复它,我安装了libssl1.0.2和libssl1.0.0。值得一提的是,我没有~/.pip/pip.conf文件,创建它也没有解决这个错误。

最终解决这个问题的方法是再次使用make安装python3.6。 下载Python-3.6.0。从网站TGZ,运行配置,然后使,使测试,使安装。希望这对你有用。

同意mastaBlasta的回答。为我工作。我遇到了与主题描述相同的问题。

环境:MacOS Sierra。我用的是自制啤酒。

我的解决方案:

重新安装openssl安装openssl 根据Homebrew提供的提示,执行以下操作: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile . bat 出口LDFLAGS =“- l / usr /地方/ opt / openssl / lib” 出口CPPFLAGS = " - i / usr /地方/ opt / openssl /包括“

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

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

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

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

brew switch openssl 1.0.2e

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