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


当前回答

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

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

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

其他回答

如果你使用的是Red Hat/CentOS:

# To allow for building python ssl libs
yum install openssl-devel
# Download the source of *any* python version
cd /usr/src
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
tar xf Python-3.6.2.tar.xz 
cd Python-3.6.2

# Configure the build w/ your installed libraries
./configure

# Install into /usr/local/bin/python3.6, don't overwrite global python bin
make altinstall

如果你在Windows上使用anaconda,这对我来说是有效的:

我尝试了很多其他的解决方案,但没有工作(环境路径变量变化…)

该问题可能是由其他软件放置在Windows\System32文件夹中的dll(例如libcrypto-1_1-x64.dll或libssl-1_1-x64.dll或其他)引起的。

修复方法是从https://slproweb.com/products/Win32OpenSSL.html安装openSSL,它将dll替换为最新版本。

如果你在Windows上使用Anaconda,你可以尝试在Anaconda提示符中运行“pip install…”命令,而不是cmd.exe,就像用户willliu1995在这里建议的那样。这对我来说是最快的解决方案,不需要安装额外的组件。

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

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

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

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

我尝试使用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,运行配置,然后使,使测试,使安装。希望这对你有用。