pyenv:构建失败(Ubuntu 15.04 使用 python-build 20160509)

pyenv: BUILD FAILED (Ubuntu 15.04 using python-build 20160509)

我已经在我的系统上安装了pyenv,命令pyenv install --list运行良好。但是当我使用pyenv install 2.7.11下载一些Python版本时,结果如下:

Downloading Python-2.7.11.tgz...
-> https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
error: failed to download Python-2.7.11.tar.gz

BUILD FAILED (Ubuntu 15.04 using python-build 20160509)

我在官方上没有发现类似的问题Common build problems

是不是pyenv没有赶上新的Ubuntu更新?

要使用 pyenv 安装 python,命令 pyenv install -v 2.7.11 可能显示比 pyenv install 2.7.11 更多的消息。所以我很容易找到错误。这次我得到了

curl: (77) error setting certificate verify locations: CAfile:
/etc/pki/tls/certs/ca-bundle.crt
CApath: none

这个问题已经在curl: (77) error

中解决了
# sudo apt-get install ca-certificates

问题是 curl 期望证书位于路径 /etc/pki/tls/certs/ca-bundle.crt 但找不到它,因为它位于路径 /etc/ssl/certs/ca-certificates.crt.

正在通过 运行

将我的证书复制到预期的目的地
sudo cp /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt

对我有用。如果 运行

不存在,则需要为目标目的地创建文件夹
sudo mkdir -p /etc/pki/tls/certs

如果需要,修改上述命令以使目标文件名与 curl 预期的路径匹配,即将 /etc/pki/tls/certs/ca-bundle.crt 替换为错误消息中 "CAfile:" 之后的路径。

命令pyenv install -v 2.7.11给了我一个类似的错误。

安装 pyenv 要求解决了我的问题:

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

(参见https://github.com/pyenv/pyenv/wiki/Common-build-problems

然后:

pyenv install 2.7.11

默认安装的curl不支持https协议。您可以使用 "curl --version" 检查。你可以找到 http 但找不到 https。

因此您需要参考 how to install curl and libcurl.

重新安装 curl
./configure --prefix=$YOUR_DIR --with-ssl
make
make install

或者找到你安装 ssl 的位置,例如 /opt/OpenSSL

./configure --with-ssl=/opt/OpenSSL

制作 安装

how to install curl and libcurl

我遇到了类似的问题。我正在使用 fedora 29 并尝试安装 python 2.7.5。下面是错误输出。

BUILD FAILED (Fedora 29 using python-build 1.2.9-35-gb6109093)
Inspect or clean up the working tree at /tmp/python-build.20190405111845.17497
./python -E -S -m sysconfig --generate-posix-vars Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] make: *** [Makefile:464: pybuilddir.txt] Segmentation fault (core dumped)

我正在寻找解决方案然后偶然发现了这个 thread.。其中说:--

issue was a longstanding in Python < 2.7.15, and recently triggered with recent compiler. They fixed it in 3.x, and backported into 2.7.15. So instead of just gathering the patch back, maybe it's best to update our 2.x version to 2.7.15 with the cross compilation patches. I'm a little bit afraid of the implication (ssl certificates issues on 2.7.x at some point).

我尝试使用 pyenv install 2.7.15 安装 2.7.15,并且安装没有错误。