用pyenv安装python时错误 Missing the zlib

第一次安装的时候报错如下

python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-2.7.15.tar.xz...
-> https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tar.xz
Installing Python-2.7.15...
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.14.2 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/mq/x_p70p7x5z57b60ms_r4jmm00000gn/T/python-build.
20190130113948.42625
Results logged to /var/folders/mq/x_p70p7x5z57b60ms_r4jmm00000gn/T/python-build.20190130113948.42625.l
og

Last 10 log lines:
rm -f /Users/vincent/.pyenv/versions/2.7.15/share/man/man1/python.1
(cd /Users/vincent/.pyenv/versions/2.7.15/share/man/man1; ln -s python2.1 python.1)
if test "xno" != "xno"  ; then \
                case no in \
                        upgrade) ensurepip="--upgrade" ;; \
                        install|*) ensurepip="" ;; \
                esac; \
                 ./python.exe -E -m ensurepip \
                        $ensurepip --root=/ ; \
        fi

解决办法

1.用brew安装zlib

brew install zlib

2.设置环境变量

# For compilers to find zlib you may need to set:
  export LDFLAGS="-L/usr/local/opt/zlib/lib"
  export CPPFLAGS="-I/usr/local/opt/zlib/include"

# For pkg-config to find zlib you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/zlib/lib/pkgconfig"

3.再次安装

pyenv install 2.7.15

成功!! 原文链接: The Python zlib extension was not compiled. Missing the zlib

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,490评论 0 10
  • pyenv,是用来管理电脑不同版本的python的一个管理工具,切换不同版本不会影响到系统自带的python。 p...
    bd4d0d78f248阅读 3,327评论 1 51
  • 没想到现在竟然有机会强制学习Python。。。 Background 刚开始时时间太匆忙,为了完成作业就先往系统里...
    ANTI_JAM阅读 2,708评论 1 1
  • 烦躁、郁闷、纠结了一上午.... 因今早起和老公吵了一架... 早上不知道怎么的起来就开始烦,大宝起来去上学,现在...
    旺火火阅读 175评论 0 1
  • gettype() gettype 会根据 参数类型返回下列值 “boolean”(从 PHP 4 起) “int...
    gentleman233阅读 3,005评论 0 0