pyenv installでエラーになるときの対応

macOS(正確にはEl Capitan)のpyenvで特定のバージョンのpythonをインストールしようとしたときにエラーになることがありました。曰く:

$ pyenv install 2.7.12                                                                                                               +[master]Downloading Python-2.7.12.tar.xz…-> https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xzInstalling Python-2.7.12…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

調べると、 zlibのヘッダが見つかってないのでCFLAGS環境変数を設定するか、xcode-select –install を実行してXCodeコマンドラインツールを再度設定するとのこと(OSをアップグレードした後とかは必要だそう)。

今回はxcode-selectのほうを試して正常にインストールできるようになりました。

$ xcode-select –install   

として出てくるダイアログ経由でXcodeのコマンドラインツールをインストールしたあと、

$ pyenv install 2.7.12                                                                                                               +[master]Downloading Python-2.7.12.tar.xz…-> https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xzInstalling Python-2.7.12…Installed Python-2.7.12 to /Users/Kurosawa_Hiroyuki/.pyenv/versions/2.7.12 

としてインストールが成功するようになりました。

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA