前の日 / 2017-02
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

2017-02-14 Tue

macos上のpyenvで任意のPythonのインストールに失敗したら

pyenvでPython 3.6.0使おうと思ってinstallしてみたら「zipimport.ZipImportError: can't decompress data; zlib not available」って言われてコンパイル失敗。

pyenvは最新版。macosは10.11.3のEl Capitan。

僕はPythonのインストールすらできないのか。

[overlast@]$pyenv install 3.6.0
Downloading openssl-1.0.2g.tar.gz...
-> https://yyuu.github.io/pythons/b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33
Installing openssl-1.0.2g...
Installed openssl-1.0.2g to /Users/overlast/.pyenv/versions/3.6.0

Downloading readline-6.3.tar.gz...
-> https://yyuu.github.io/pythons/56ba6071b9462f980c5a72ab0023893b65ba6debb4eeb475d7a563dc65cafd43
Installing readline-6.3...
Installed readline-6.3 to /Users/overlast/.pyenv/versions/3.6.0

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...

BUILD FAILED (OS X 10.11.3 using python-build 1.0.7-12-g235eea3)

Inspect or clean up the working tree at /var/folders/xy/g9d8p2x14kz1f82097l4fx140000gp/T/python-build.20170213192331.22487
Results logged to /var/folders/xy/g9d8p2x14kz1f82097l4fx140000gp/T/python-build.20170213192331.22487.log

Last 10 log lines:
  File "/private/var/folders/xy/g9d8p2x14kz1f82097l4fx140000gp/T/python-build.20170213192331.22487/Python-3.6.0/Lib/ensurepip/__main__.py", line 4, in <module>
    ensurepip._main()
  File "/private/var/folders/xy/g9d8p2x14kz1f82097l4fx140000gp/T/python-build.20170213192331.22487/Python-3.6.0/Lib/ensurepip/__init__.py", line 189, in _main
    default_pip=args.default_pip,
  File "/private/var/folders/xy/g9d8p2x14kz1f82097l4fx140000gp/T/python-build.20170213192331.22487/Python-3.6.0/Lib/ensurepip/__init__.py", line 102, in bootstrap
    _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/private/var/folders/xy/g9d8p2x14kz1f82097l4fx140000gp/T/python-build.20170213192331.22487/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


なるほど。こういう意味不明なエラーはLinuxでは出ないからXCodeがらみっぽい。

zlibのインストール


こういうときは、まずはzlibを入れ直す。

[overlast@]$brew install zlib
==> Installing zlib from homebrew/dupes
==> Downloading https://homebrew.bintray.com/bottles-dupes/zlib-1.2.11.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring zlib-1.2.11.el_capitan.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/zlib/lib
    CPPFLAGS: -I/usr/local/opt/zlib/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/zlib/lib/pkgconfig

==> Summary
🍺  /usr/local/Cellar/zlib/1.2.11: 12 files, 374.5K



xcode-selectのインストール


次にmacos使ってるときは、xcode-selectを入れ直す。
実行したらmacosがxcode-selectをダウンロードしてくれる。

[overlast@]$ xcode-select --install
xcode-select: note: install requested for command line developer tools


ここまでやったら一旦、Pythonのinstallを試みる。

[overlast@]$pyenv install 3.6.0
Downloading openssl-1.0.2g.tar.gz...
-> https://yyuu.github.io/pythons/b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33
Installing openssl-1.0.2g...
Installed openssl-1.0.2g to /Users/overlast/.pyenv/versions/3.6.0

Downloading readline-6.3.tar.gz...
-> https://yyuu.github.io/pythons/56ba6071b9462f980c5a72ab0023893b65ba6debb4eeb475d7a563dc65cafd43
Installing readline-6.3...
Installed readline-6.3 to /Users/overlast/.pyenv/versions/3.6.0

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...
Installed Python-3.6.0 to /Users/overlast/.pyenv/versions/3.6.0


いけた。

今回はいろいろあって何故かmacos上で書いてるから、いろいろ対処方法が未知な不具合で困りそう。


投稿者:としのり  日時:23:59:59 | コメント | トラックバック |