Macのpyenvでconfigure: error: C compiler cannot create executables

Macでpyenv installしようとしたところ表題のエラー。

% pyenv install 3.8.4
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Installing Python-3.8.4...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 10.15.7 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/k6/z1nv88hn50lbyt0jk334wlqr0000gn/T/python-build.20201015235728.20206
Results logged to /var/folders/k6/z1nv88hn50lbyt0jk334wlqr0000gn/T/python-build.20201015235728.20206.log

Last 10 log lines:
checking for python3.8... python3.8
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "darwin"
checking for gcc... clang
checking whether the C compiler works... no
configure: error: in `/var/folders/k6/z1nv88hn50lbyt0jk334wlqr0000gn/T/python-build.20201015235728.20206/Python-3.8.4':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.

Cのコンパイラがおかしいらしい。

% gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.2)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

% which gcc
/usr/bin/gcc

試しに適当なソースコードをビルドしてみたが、問題なく完了した。

pyenvのよくある質問コーナーを見てみたけど、Cコンパイラに関連した記述は特に見当たらない。

Common build problems
Simple Python version management. Contribute to pyenv/pyenv development by creating an account on GitHub.

何が原因かはっきりわからなかったので、pyenvを再インストールすることにした。

% brew uninstall pyenv-virtualenv
% brew uninstall pyenv
% brew list # pyenvが無いことを確認

% brew install pyenv
% brew install pyenv-virtualenv

% pyenv install 3.8.4
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.4.tar.xz...
-> https://www.python.org/ftp/python/3.8.4/Python-3.8.4.tar.xz
Installing Python-3.8.4...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.8.4 to /Users/coco/.pyenv/versions/3.8.4

なぜこうなったのかは分からなかったが、再インストールすることで無事にpyenv installが出来るようになった。

コメント

  1. […] Macのpyenvでconfigure: error: C compiler cannot create executables […]

タイトルとURLをコピーしました