pyenv install時にzlibがコンパイルされていないよエラーが出た場合の対処方法。

OSX + anyenv + pyenv環境下で新しいPython環境をインストールしようとして、以下のようなエラーが起きた時。Maverics時代に遭遇した覚えがないので、Capitanに更新したせいかなぁ?

$ pyenv install 3.3.6
Downloading Python-3.3.6.tgz...
-> https://www.python.org/ftp/python/3.3.6/Python-3.3.6.tgz
Installing Python-3.3.6...
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
ERROR: The Python zlib extension was not compiled. Missing the zlib?

ご丁寧に、以下のメッセージも出力されます。問題解決するには以下を見ろと。

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

解決方法として、以下の手順が上がっていました。

  • Mac OS X: brew install readline xz
  • On Mac OS X 10.9, 10.10 and 10.11 you may need to set the CFLAGS environment variable when installing a new version in order for configure to find the zlib headers (XCode command line tools must be installed first):CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 2.7.7

readlineやxzはインストール済みだったので、次のCFLAGS設定を試そうとしましたが、以下の記述もあり。

  • Alternatively, try reinstalling XCode command line tools for your OS (especially if you just upgraded your OS)xcode-select --install

pyenv installするたびにCFLAGS設定したりエイリアス設定するのは面倒なので、おとなしくxcode-selectしてみると…。

$ pyenv install 3.3.6
Installing Python-3.3.6...
Installing pip from https://bootstrap.pypa.io/get-pip.py...
Installed Python-3.3.6 to /Users/takashi/.anyenv/envs/pyenv/versions/3.3.6

うまくいきました。
XCode command line toolsって、いろんなところに影響するなぁ。

シェアする

  • このエントリーをはてなブックマークに追加

フォローする

Close Bitnami banner
Bitnami