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

其他回答

我也遇到了同样的问题,并能够通过以下步骤解决:

sudo yum install -y libffi-devel
sudo yum install openssl-devel
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
sudo tar xf Python-3.7.1.tar.xz
cd Python-3.7.1
sudo ./configure --enable-optimizations
# Install into /usr/local/bin/python3.7, don't overwrite global python bin
sudo make altinstall

根据烫发的不同,你可能不需要sudo。

Results:
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1

现在应该可以运行了吗

python3.7 -V 

and

pip3.7 -V

安装包时:

pip3.7 install pandas

或者根据烫发,你也可以像这样添加——user标志:

pip3.7 install pandas --user

同意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 /包括“

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

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

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

这对我很有用;)

在Ubuntu中,这可以帮助:

cd Python-3.6.2
./configure --with-ssl
make
sudo make install

在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中测试。