こちらの記事を見ながら進めています。
行った手順は下記の通りです。Homebrewとpyenvのインストールと設定はできています。
% brew -v
Homebrew 4.0.28
% pyenv -v
pyenv 2.3.22
エラーが起きたところ
# インストールできるPythonのバージョンを確認
% pyenv install --list
(省略)
stackless-3.7.5
# ↓インストールを試みるもエラー
% pyenv install 3.7.5
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.5.tar.xz...
-> https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tar.xz
Installing Python-3.7.5...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
BUILD FAILED (OS X 13.4.1 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/gr/mr4d6zsd2x5962flyffsp2d00000gn/T/python-build.20230710205839.15224
Results logged to /var/folders/gr/mr4d6zsd2x5962flyffsp2d00000gn/T/python-build.20230710205839.15224.log
Last 10 log lines:
checking for --with-cxx-main=<compiler>... no
checking for clang++... no
configure:
By default, distutils will build C++ extension modules with "clang++".
If this is not intended, then set CXX on the configure command line.
checking for the platform triplet based on compiler characteristics... darwin
configure: error: internal configure error for the platform triplet, please file a bug report
make: *** No targets specified and no makefile found. Stop.
% pyenv versions
* system (set by /Users/chiharatomoya/.pyenv/version)
インストールできていませんでした。
試したこと
上記の記事を参考に、以下の手順を何度か試してみましたが、変わりませんでした。
# 古いツールの削除
$ sudo rm -rf /Library/Developer/CommandLineTools
# 新しいCommandLineToolsのインストール
$ xcode-select --install
$ pyenv install 3.7.5
中でも下記のエラーでググると、やはり古いツールを削除してから再度CommandLineToolsをインストールするようにという記事しか出ませんでした。
% xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" in System Settings to install updates
なので何度か古いツールの削除→CommandLineToolsのインストールを繰り返してみましたが、ループするだけでした。
その後さらに下記の記事を試してみるも変わらず、、
% brew install zlib
% echo 'export LDFLAGS="-L/usr/local/opt/zlib/lib"' >> ~/.zshrc
% echo 'export CPPFLAGS="-I/usr/local/opt/zlib/include"' >> ~/.zshrc
% echo 'export PKG_CONFIG_PATH="/usr/local/opt/zlib/lib/pkgconfig"' >> ~/.zshrc
原因
そもそもインストールしようとしているバージョンが間違ってる。
% pyenv install -l
でずらーっと出てきたので、一番下のstackless-3.7.5
がてっきりPythonの最新バージョンかと思いpyenv install 3.7.5
を実行したのですが、Pythonのバージョンはたくさん出てきた中の真ん中の方に書いてありました。
とにかく凡ミスです。。
% pyenv install -l
(省略)
3.10.11
3.10.12
3.11.0
(省略)
stackless-3.5.4
stackless-3.7.5
stacklessの他にもpypyやminiforgeなどいろいろ並んでますが、数字だけ書いてあるのがインストール可能なPythonのバージョンです。
解決
% pyenv install 3.11.4
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.11.4.tar.xz...
-> https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tar.xz
Installing Python-3.11.4...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.11.4 to /Users/chiharatomoya/.pyenv/versions/3.11.4
% pyenv versions
* system (set by /Users/chiharatomoya/.pyenv/version)
3.11.4
% pyenv global 3.11.4
% python --version
Python 3.11.4
無事インストールできました!