我尝试在 pyenv env 中安装 Python,但出现以下错误。我已将 openssl 添加到路径变量中,因为 openssl 已经可用,但它仍然抛出相同的错误。
此外,我尝试使用单独的用户(不是 root)。同样的错误!我尝试遵循维基页面(https://github.com/pyenv/pyenv/wiki/Common-build-problems#error-the-python-ssl-extension-was-not-compiled-missing-the- openssl-lib),但是对于 OpenSUSE 我在 google 上也找不到太多帮助。
有人可以指导我如何进一步进行吗?
xxxxx@xxxxxxxxxxx:~/.pyenv> pyenv install 3.5.2
Downloading Python-3.5.2.tar.xz...
-> https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
Installing Python-3.5.2...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
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/yyuu/pyenv/wiki/Common-build-problems
BUILD FAILED (SLES 12.1 using python-build 20160726)
Inspect or clean up the working tree at /tmp/python-build.20160801100205.31144
Results logged to /tmp/python-build.20160801100205.31144.log
Last 10 log lines:
(cd /home/xxxxx/.pyenv/versions/3.5.2/share/man/man1; ln -s python3.5.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 8.1.1 requires SSL/TLS
这里有一个解决构建问题的官方指南https://github.com/pyenv/pyenv/wiki/common-build-problems
因此,对于 openSuse,您必须首先安装依赖项:
zypper in zlib-devel bzip2 libbz2-devel libffi-devel libopenssl-devel \
readline-devel sqlite3 sqlite3-devel xz xz-devel
也适用于 Ubuntu/Debian:
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
Python 利用底层操作系统库来支持其某些库,但您似乎没有安装这些库。在 Ubuntu 上你应该能够安装它们
$ sudo apt-get install bzip2 libreadline6 libreadline6-dev openssl
对于 SUSE 12,正如您所指出的,所需的命令是
zypper -n install openssl libopenssl-devel
编辑 2023 年 9 月 30 日: 但请注意,除非您要创建虚拟映像,否则将所需的功能安装到系统 Python 中是不好的做法。 相反,使用它(或您自己安装的不同 Python 版本)来创建虚拟环境,并在其中安装必要的依赖项。这样,您就不会因为不必要的(并且可能是冲突的)依赖项而使其他项目的环境变得混乱。
除了上述答案之外,我还必须:
sudo apt-get install python-openssl
sudo apt install libssl1.0-dev
帮助了我
对我来说,上面的内容在 Ubuntu 18.04 上不起作用。我有 openssl 和 openssl-dev 以及 python-openssl。但它与 openssl1.0-dev 一起工作,所以:
$ sudo apt-get install openssl1.0-dev
这对我有用:
sudo apt install libssl-dev