无法通过pyenv zlib错误

时间:2017-11-10 15:55:55

标签: python pyenv

使用pyenv安装其他python版本时遇到了很多麻烦。我总是得到这个zlib构建错误。我已经尝试了wiki中的所有内容。

python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-2.7.3.tgz...
-> https://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
Installing Python-2.7.3...
patching file ./Modules/readline.c
Hunk #1 succeeded at 200 (offset -6 lines).
Hunk #2 succeeded at 735 (offset -14 lines).
Hunk #3 succeeded at 845 (offset -14 lines).
Hunk #4 succeeded at 893 with fuzz 2 (offset -25 lines).
patching file ./Lib/site.py
patching file ./Lib/ssl.py
Hunk #2 succeeded at 424 (offset -11 lines).
patching file ./Modules/_ssl.c
Hunk #1 succeeded at 65 (offset -2 lines).
Hunk #2 succeeded at 304 (offset -4 lines).
Hunk #3 succeeded at 1725 (offset -87 lines).
python-build: use readline from homebrew
ERROR: The Python zlib extension was not compiled. Missing the zlib?

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


BUILD FAILED (OS X 10.12.2 using python-build 1.1.5-38-g428a94b)

Inspect or clean up the working tree at /var/folders/3w/p2g7w8bs13778xbvqfb1hlqwgkr9wz/T/python-build.20171111043756.36564
Results logged to /var/folders/3w/p2g7w8bs13778xbvqfb1hlqwgkr9wz/T/python-build.20171111043756.36564.log

Last 10 log lines:
(cd /Users/clement.oh/.pyenv/versions/2.7.3/bin; ln -s python2-config python-config)
test -d /Users/clement.oh/.pyenv/versions/2.7.3/lib/pkgconfig || /usr/bin/install -c -d -m 755 /Users/clement.oh/.pyenv/versions/2.7.3/lib/pkgconfig
rm -f /Users/clement.oh/.pyenv/versions/2.7.3/lib/pkgconfig/python2.pc
(cd /Users/clement.oh/.pyenv/versions/2.7.3/lib/pkgconfig; ln -s python-2.7.pc python2.pc)
rm -f /Users/clement.oh/.pyenv/versions/2.7.3/lib/pkgconfig/python.pc
(cd /Users/clement.oh/.pyenv/versions/2.7.3/lib/pkgconfig; ln -s python2.pc python.pc)
Creating directory /Users/clement.oh/.pyenv/versions/2.7.3/share/man
Creating directory /Users/clement.oh/.pyenv/versions/2.7.3/share/man/man1
/usr/bin/install -c -m 644 ./Misc/python.man \
        /Users/clement.oh/.pyenv/versions/2.7.3/share/man/man1/python2.7.1

1 个答案:

答案 0 :(得分:1)

尝试一下:

CFLAGS="-I$(brew --prefix readline)/include -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" \
LDFLAGS="-L$(brew --prefix readline)/lib -L$(brew --prefix openssl)/lib" \
PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs2 \
pyenv install -v 2.7.3

从这里:https://medium.com/@pimterry/setting-up-pyenv-on-os-x-with-homebrew-56c7541fd331