I have pyenv setup on my Macbook Pro M2 2022 Sonoma 14.6, which was migrated from an Intel-based chip a long while back. I was able to install and run python v3.10.13 via pyenv no problem but when I try to install python 3.10.15, the build fails, and I can't figure out why. I've tried both reinstalling Homebrew and reinstalling command line tools, but the problem persists. Any ideas?
python -V
Python 3.10.13
pyenv install 3.10.15
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.10.15.tar.xz...
-> https://www.python.org/ftp/python/3.10.15/Python-3.10.15.tar.xz
Installing Python-3.10.15...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
BUILD FAILED (OS X 14.6 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/4h/8h2hjqjx659_l93m2_2qbqbw0000gn/T/python-build.20250107151340.62026
Results logged to /var/folders/4h/8h2hjqjx659_l93m2_2qbqbw0000gn/T/python-build.20250107151340.62026.log
Last 10 log lines:
ld: warning: duplicate -rpath '/opt/homebrew/lib' ignored
ld: warning: duplicate -rpath '/Users/kalicious/.pyenv/versions/3.10.15/lib' ignored
ld: warning: duplicate -rpath '/opt/homebrew/lib' ignored
ld: warning: search path '/Users/kalicious/.pyenv/versions/3.10.15/lib' not found
ld: warning: search path '/Users/kalicious/.pyenv/versions/3.10.15/lib' not found
ld: warning: search path '/Users/kalicious/.pyenv/versions/3.10.15/lib' not found
/opt/local/bin/ranlib: object: libpython3.10.a(getbuildinfo.o) malformed object (unknown load command 1)
ar: internal ranlib command failed
make: *** [libpython3.10.a] Error 1
make: *** Waiting for unfinished jobs....
To follow up about this, as it turns out my issue was that I had an old broken version of MacPorts installed on my machine. Removing MacPorts fixed the problem for me.
See this thread for more info: https://github.com/pyenv/pyenv/issues/3158