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

其他回答

我做了一些PATH更改,以模仿Anaconda Powershell提示$env:PATH的一部分

C:\Users\merheb\Miniconda3;C:\Users\merheb\Miniconda3\Library\mingw-w64\bin;C:\Users\merheb\Miniconda3\Library\usr\bin;C:\Users\merheb\Miniconda3\Library\bin;C:\Users\merheb\Miniconda3\Scripts;C:\Users\merheb\Miniconda3\bin;C:\Users\merheb\Miniconda3\condabin;

这招对我很管用。

在Ubuntu中安装Python 3.6和pip3的分步指南

安装Python和ssl所需的包:$ sudo apt-get Install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev 下载并解压“Python-3.6.8.tar. zip”。Xz”从https://www.python.org/ftp/python/到您的主目录。 打开该目录下的终端,执行:$ ./configure 编译和安装:$ make && sudo make install 使用$ pip3 Install package_name安装包

声明:以上命令未在Ubuntu 20.04 LTS中测试。

如果你在OSX上,万一其他解决方案不适合你(就像我一样)。

您可以尝试卸载python3并升级pip3

brew uninstall --ignore-dependencies python3
pip3 install --upgrade pip   

这对我很有用;)

我在ubuntu14.04机器上安装python3.7时遇到了同样的问题。 问题是我的PKG_CONFIG_PATH和LD_LIBRARY_PATH中有一些自定义文件夹,这阻止了python构建过程找到系统openssl库。

所以试着清除它们,看看会发生什么:

export PKG_CONFIG_PATH=""
export LD_LIBRARY_PATH=""

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

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

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

brew switch openssl 1.0.2e

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