LoginSignup
613
240

More than 5 years have passed since last update.

[MacOS Mojave]pyenvでpythonのインストールがzlibエラーで失敗した時の対応

Last updated at Posted at 2018-09-30

先日、macOS High SierraからmacOS Mojave 10.14にOS更新かけました。

その後pyenv 1.2.7で新しいpythonバージョンをインストールしようとすると、よくあるzlibエラーが出るようになりました:

pyenv install 3.6.0
180930202414.28657/Python-3.6.0/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1

High Sierra以前ではこれは基本的にxcode-select --install で直せたが、Mojaveではそう上手く行かないようです。

また、brew install zlib で試してもzlibが既にインストールされていると表示される。

Warning: zlib 1.2.11 is already installed and up-to-date
To reinstall 1.2.11, run `brew reinstall zlib`


解決策

xcode-selectの最新バージョン(2354)にMojave用のmacOS SDK headerがデフォルトで入っていないのが原因のようです。

マニュアルで以下をインストールする必要ある:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

すると、pyenvでのzlib問題が解決されるはずです(下記のようなものが出ればとりあえずオケ。)

zreactor$ pyenv install 3.6.0
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.6.0.tar.xz...
-> https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
Installing Python-3.6.0...
python-build: use readline from homebrew
Installed Python-3.6.0 to /Users/zreactor/.pyenv/versions/3.6.0

Mac Mojaveリリース直後だからまだxcodeツールで対応が追いついていないという事なのでしょうが、今後解決されると期待ですね。

613
240
11

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
613
240