1
0

More than 1 year has passed since last update.

pyenvでビルドが失敗して、pythonをインストールできない

Posted at

Pythonのインストールでエラーが出た

Atcoderを始めるため、pythonの環境を用意しようとpyenvをインストールし、

$ pyenv install 3.9.1

を実行すると下記のようにエラーが出た。

python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.1.tar.xz...
-> https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tar.xz
Installing Python-3.9.1...
patching file Misc/NEWS.d/next/Build/2021-10-11-16-27-38.bpo-45405.iSfdW5.rst
patching file configure
patching file configure.ac
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

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

"build failed (os x 12.4 using python-build 20180424)"より、ビルドに失敗しているのかと思った。
すると、pyenvの公式でビルドの失敗に関する様々なissueを発見したが、しっくりこない。

pyenvはhomebrewでインストールしたので、下記のHomebrewの問題チェックコマンドを実行してみた。

$ brew doctor

すると、Xcodeに関するwarningが出ていた。

Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 13.3.

pyenvのエラーにもXcodeに関することが書かれていたので、xcodeのアップデートを試してみることに。

$ sudo rm -rf /Library/Developer/CommandLineTools
$ sudo xcode-select --install

を実行して、再度python install 3.9.1をすると、インストールに成功した。

結論

Xcodeのアップデートが必要だったらしい。
$brew doctorでHomebrewのwarningを確認しようとしたのが、エラー解決に繋がった。
pyenv公式のissueで同じ解決法の人が見当たらなかったので、エラーから問題の仮説を立てて、解決に辿り着けてよかった。

1
0
0

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
1
0