安装 Python 时出现 pip 错误:“忽略 ensurepip 失败:pip 8.1.1 需要 SSL/TLS”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37723236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 19:51:34  来源:igfitidea点击:

pip error while installing Python: "Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS"

pythoninstall

提问by gil Got

I downloaded the Python 3.5 source code and ran the following:

我下载了 Python 3.5 源代码并运行了以下命令:

$ tar -xf Python-3.5.2.tar.xz
$ ./configure --with-ensurepip=upgrade
$ make
$ sudo make altinstall

It proceeded well until make. When sudo make altinstallran, it printed:

它进行得很好,直到make。当sudo make altinstall然,它印:

Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS

Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS

What went wrong?

什么地方出了错?

回答by eandersson

You are most likely not compiling Python with SSL/TLS support - this is likely because you don't have the SSL development dependencies installed on your system.

您很可能没有使用 SSL/TLS 支持编译 Python - 这可能是因为您的系统上没有安装 SSL 开发依赖项。

Install the following dependency, and then re-configure and re-compile Python 3.5.

安装以下依赖,然后重新配置并重新编译Python 3.5。

Ubuntu

Ubuntu

apt-get install libssl-dev

In addition it is recommended to install the following.

此外,建议安装以下内容。

apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libsqlite3-dev

CentOS

CentOS

yum install openssl-devel

In addition it is recommended to install the following.

此外,建议安装以下内容。

yum install zlib-devel bzip2-devel sqlite sqlite-devel openssl-devel

回答by Laurens

Please note that besides that as of version OpenSSL 1.1.0 (included from Ubuntu 18.04 repositories, I am not sure for other Linux distributions) there are python vesions that may have compilation issues (see this questionand my answer), in short:

请注意,除了 OpenSSL 1.1.0 版本(包含在 Ubuntu 18.04 存储库中,我不确定其他 Linux 发行版)之外,还有可能存在编译问题的 Python 版本(请参阅此问题我的答案),简而言之:

Python <3.4.5 and Python <3.5.3 have not implemented this newest version of OpenSSL, most likely other major Python versions suffer the same issue. The fix is to download the minor version that implements the fix (or newer). Check the full changelogs to check which minor version that is (changelog for 3.4and 3.5)

Python <3.4.5 和 Python <3.5.3 尚未实现此最新版本的 OpenSSL,很可能其他主要 Python 版本也遇到同样的问题。修复是下载实现修复(或更新)的次要版本。检查完整的变更日志以检查是哪个次要版本(3.43.5 的变更日志)

回答by Jozef Cechovsky

On Ubuntu 18.04 only this worked for me

在 Ubuntu 18.04 上只有这对我有用

sudo apt-get install libssl1.0

回答by user4212639

CentOS:

中央操作系统

If you didn't have openssl-develat the time of installing python, pip 8.1.1 won't install. After installing openssl-devel, reinstall python. This time it should install pipjust file.

如果你openssl-devel在安装 python 时没有,pip 8.1.1 将不会安装。安装后openssl-devel,重新安装python。这次它应该pip只安装文件。

回答by Andrey Semakin

I tried to install Python 3.4.10 using asdfbut got following error:

我尝试使用安装 Python 3.4.10asdf但出现以下错误:

$ asdf install python 3.4.10
python-build 3.4.10 /home/br0ke/.asdf/installs/python/3.4.10
Downloading Python-3.4.10.tar.xz...
-> https://www.python.org/ftp/python/3.4.10/Python-3.4.10.tar.xz
Installing Python-3.4.10...
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (Fedora 30 using python-build 1.2.15-2-g22c02022)

Inspect or clean up the working tree at /tmp/python-build.20191121110112.9959
Results logged to /tmp/python-build.20191121110112.9959.log

Last 10 log lines:
(cd /home/br0ke/.asdf/installs/python/3.4.10/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno"  ; then \
    case upgrade in \
        upgrade) ensurepip="--upgrade" ;; \
        install|*) ensurepip="" ;; \
    esac; \
     ./python -E -m ensurepip \
        $ensurepip --root=/ ; \
fi
Ignoring ensurepip failure: pip 9.0.1 requires SSL/TLS

It may mean that I have too fresh OpenSSL version installed in my system and this version is not supported by Python I'm trying to build. I managed to install Python 3.4.10 on my Fedora 30 machine (has OpenSSL 1.1+ by default) using the following steps:

这可能意味着我的系统中安装了太新的 OpenSSL 版本,而我正在尝试构建的 Python 不支持该版本。我设法使用以下步骤在我的 Fedora 30 机器上安装了 Python 3.4.10(默认情况下有 OpenSSL 1.1+):

  1. Temporary remove openssl-devel if it is installed as it will conflict with older version:
  1. 临时删除 openssl-devel 如果它已安装,因为它会与旧版本冲突:
$ sudo dnf remove openssl-devel
  1. Install compat OpenSSL 1.0 packages:
  1. 安装兼容的 OpenSSL 1.0 软件包:
$ sudo dnf install compat-openssl10 compat-openssl10-devel
  1. Build Python 3.4.10 (I use asdfbut it should work with pyenvas well):
  1. 构建 Python 3.4.10(我使用asdf但它也应该适用pyenv):
$ asdf install python 3.4.10
  1. Remove compat library and install modern instead to be able to build something more fresh next time:
  1. 删除 compat 库并安装 Modern 以便下次能够构建更新鲜的东西:
$ sudo dnf remove compat-openssl10-devel
$ sudo dnf install openssl-devel

Inspired by this workaroundwith help from Fedora community people.

Fedora 社区人员的帮助下,受此解决方法的启发。

回答by Swastik Raj Ghosh

If you are using RedHat Enterprise Linux, you can use this:

如果您使用的是 RedHat Enterprise Linux,则可以使用以下命令:

yum install openssl-devel -y

回答by Denis L

If you use Manjaro Linux, you can use this:

如果你使用 Manjaro Linux,你可以使用这个:

sudo pacman -S openssl , check

sudo pacman -S openssl ,检查

回答by Sadashiv

CentOS or RHEL machine Python3(3.7.0) ssl not supported as of now.

目前尚不支持 CentOS 或 RHEL 机器 Python3(3.7.0) ssl。

pip installation supported with Python <=3.6

Python <=3.6 支持 pip 安装