macOS Mojave でpyenv install 3.4.3 が失敗したときの対応
pyenvでのpythonのinstallが失敗したときの対応を記録しておく。
rMBP01:~ kapi$ pyenv install 3.4.3 python-build: use openssl from homebrew python-build: use readline from homebrew Downloading Python-3.4.3.tar.xz... -> https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz Installing Python-3.4.3... python-build: use readline from homebrew BUILD FAILED (OS X 10.14.4 using python-build 20180424) Inspect or clean up the working tree at /var/folders/dj/1y_c81qj4jx9mv7zzv8zmh240000gn/T/python-build.20190509123945.6287 Results logged to /var/folders/dj/1y_c81qj4jx9mv7zzv8zmh240000gn/T/python-build.20190509123945.6287.log Last 10 log lines: checking for --without-gcc... no checking for gcc... clang checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... configure: error: in `/var/folders/dj/1y_c81qj4jx9mv7zzv8zmh240000gn/T/python-build.20190509123945.6287/Python-3.4.3': configure: error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details make: *** No targets specified and no makefile found. Stop.
config.logを調べる
$cd /var/folders/dj/1y_c81qj4jx9mv7zzv8zmh240000gn/T/python-build.20190509123945.6287/Python-3.4.3 $cat config.log ~~~~~~~ configure:3926: clang -V >&5 clang-4.0: error: argument to '-V' is missing (expected 1 value) clang-4.0: error: no input files configure:3937: $? = 1 configure:3926: clang -qversion >&5 clang-4.0: error: unknown argument: '-qversion' clang-4.0: error: no input files ~~~~~~~ configure:4105: clang -o conftest -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/Users/prokapi/.pyenv/versions/3.4.3/include -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/Users/prokapi/.pyenv/versions/3.4.3/lib conftest.c >&5 conftest.c:8:10: fatal error: 'stdio.h' file not found #include <stdio.h> ^~~~~~~~~ 1 error generated.
clangのところでerrorが発生している。 macに入っているclangを調べる。
https://teratail.com/questions/176364
which -a clang /usr/local/opt/llvm/bin/clang /usr/bin/clang
上のclangが使われていて、それだとビルドが失敗してる? /usr/bin/clang の方はx-codeのclang。本来はこっちが使われるべきでは。 上のclangは使っていないので削除することにする。
$ brew uninstall llvm Uninstalling /usr/local/Cellar/llvm/4.0.0... (2,245 files, 1GB)
再びpyenvでinstallする。
pyenv install 2.7.1
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 BUILD FAILED
今度は違うエラー。対処方法はここにあった。
https://qiita.com/TEWi_R/items/aac5bada7c17dba1a7f0
$ CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 2.7.1
ようやくpython 2.7.1のビルドができた。 3系も試してみる。
$ pyenv install 3.4.1
zipimport.ZipImportError: can't decompress data; zlib not available make: *** [install] Error 1
このエラーも対策があった。ありがとう。
https://qiita.com/zreactor/items/c3fd04417e0d61af0afe
xcode-selectの最新バージョン(2354)にMojave用のmacOS SDK headerがデフォルトで入っていないのが原因のようです。
マニュアルで以下をインストールする必要ある:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
できました!
$ pyenv install 3.4.1
これで完了。