python

pyenv installでBUILD FAILED

pythonを13にアップデートしようとしたらBUILD FAILEDと表示されて途中で終わってしまい、pythonのインストールに失敗した。

pyenv install 3.13-dev

pyenvのインストールコマンド

python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Cloning https://github.com/python/cpython...
Installing Python-3.13-dev...
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew

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

Inspect or clean up the working tree at /var/folders/1x/vjn3ynp16ys4jttzs8ktjdth7qf6mg/T/python-build.20250724114300.2996
Results logged to /var/folders/1x/vjn3ynp16ys4jttzs8ktjdth7qf6mg/T/python-build.20250724114300.2996.log

Last 10 log lines:
checking for --with-app-store-compliance... not patching for app store compliance
checking for xcrun... yes
checking macOS SDKROOT... You have not agreed to the Xcode license agreements. Please run 'sudo xcodebuild -license' from within a Terminal window to review and agree to the Xcode and Apple SDKs license.

checking for gcc... clang
checking whether the C compiler works... no
configure: error: in '/var/folders/1x/vjn3ynp16ys4jttzs8ktjdth7qf6mg/T/python-build.20250724114300.2996/Python-3.13-dev':
configure: error: C compiler cannot create executables
See 'config.log' for more details
You have not agreed to the Xcode license agreements. Please run 'sudo xcodebuild -license' from within a Terminal window to review and agree to the Xcode and Apple SDKs license.

エラー内容

最後の行に「sudo xcodebuild -license」を実行しろとあるので実行してみる。

sudo xcodebuild -license

実行後、何も表示されないのでうまくいったみたい。

再度実行してみる。

python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Cloning https://github.com/python/cpython...
Installing Python-3.13-dev...
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
ERROR: invalid Python executable: /Users/ishimoto/.pyenv/versions/3.13-dev/bin/python3.13

The python-build could not find proper executable of Python after successful build.
Please open an issue for future improvements.
https://github.com/pyenv/pyenv/issues

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

Inspect or clean up the working tree at /var/folders/1x/vjn3ynp16ys4jttzs8ktjdth7qf6mg/T/python-build.20250724114642.4133
Results logged to /var/folders/1x/vjn3ynp16ys4jttzs8ktjdth7qf6mg/T/python-build.20250724114642.4133.log

Last 10 log lines:
		esac; \
		DYLD_LIBRARY_PATH=/var/folders/1x/vjn3ynp16ys4jttzs8ktjdth7qf6mg/T/python-build.20250724114642.4133/Python-3.13-dev ./python.exe -E -m ensurepip \
			$ensurepip --root=/ ; \
	fi
Looking in links: /var/folders/1x/vjn3ynp16ys4jttzs8ktjdth7qf6mg/T/tmpo72zvb77
Processing /var/folders/1x/vjn3ynp16ys4jttzs8ktjdth7qf6mg/T/tmpo72zvb77/pip-25.1.1-py3-none-any.whl
Installing collected packages: pip
  WARNING: The scripts pip3 and pip3.15 are installed in '/Users/ishimoto/.pyenv/versions/3.13-dev/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-25.1.1

また失敗した。

pyenv自体のアップデートが必要な模様

brew upgrade pyenv

私はhomebrewでpyenvをインストールしていたので、brewコマンドでpyenvアップデート

再度実行してみる。

python-build: use openssl@3 from homebrew
python-build: use readline from homebrew
Downloading Python-3.13.1.tar.xz...
-> https://www.python.org/ftp/python/3.13.1/Python-3.13.1.tar.xz
Installing Python-3.13.1...
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use ncurses from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.13.1 to /Users/ishimoto/.pyenv/versions/3.13.1

成功しました。