在Archlinux上通过Pyenv编译Python但缺少OpenSSL

时间:2017-05-15 09:38:14

标签: python archlinux pyenv

我正在尝试通过pyenv在我的新ArchLinux安装

上安装python
pyenv install 3.5.1Downloading Python-3.5.1.tar.xz...
-> https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz
Installing Python-3.5.1...
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 (Arch Linux using python-build 20160602)

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

Last 10 log lines:
(cd /home/maximilian/.pyenv/versions/3.5.1/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 7.1.2 requires SSL/TLS

由于缺少OpenSSL支持而导致错误。我在之前的Arch安装中运行它,但我不记得我当时做了什么。

Wiki中的常见问题解答不提供可行的解决方案

2 个答案:

答案 0 :(得分:8)

请试试。:

CFLAGS=-I/usr/include/openssl-1.0 \
LDFLAGS=-L/usr/lib64/openssl-1.0 \
pyenv install -v 3.5.1

ArchLinux包:

$ pacman -Q | grep openssl
openssl 1.1.0.e-1
openssl-1.0 1.0.2.k-3
python-pyopenssl 17.0.0-1
python2-pyopenssl 17.0.0-1

答案 1 :(得分:1)

pyvenv FAQ mention an issue similar to what you are reporting。他们的解决方案是使用

CFLAGS=-I/usr/include/openssl \
LDFLAGS=-L/usr/lib64 \
pyenv install -v 3.5.1

此外,不是Python需要SSL而只是pip。 Arch拥有自己的Python 3包compiles with --without-ensurepip,所以你可以尝试

CONFIGURE_OPTS="--without-ensurepip" \
pyenv install -v 3.5.1