状況
macOS Mojave で pyenv を使って python2.7.x をインストールした時に下記のエラーが出た場合の対処方法。
Installing Python-2.7.16...
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.6 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/ml/r0_f1xbn5yl2fwql2wzczcf80000gn/T/python-build.20190802192417.48871
Results logged to /var/folders/ml/r0_f1xbn5yl2fwql2wzczcf80000gn/T/python-build.20190802192417.48871.log
...
参考
解決方法
$ brew install readline xz
$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
pkg ファイルのバージョンは macOS のバージョンに合わせて読みかえる必要があります。また、最新の情報については参考 URL を参照する必要があります。