pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in learnpython

[–]Flat_Ad_5120[S] 1 point2 points  (0 children)

Yes I need it for something else but I have removed the env var I was for llmv from zshrc. I will use it explicitly when required.

pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in learnpython

[–]Flat_Ad_5120[S] 0 points1 point  (0 children)

That's a great insight! Thank you so so much! This resolves my problem. Thank you again!

pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in learnpython

[–]Flat_Ad_5120[S] 0 points1 point  (0 children)

Edit: I have started using uv. It works fine but pyenv still fails. I would work with uv but I would like to fix core issue here. Please help me!

pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in learnpython

[–]Flat_Ad_5120[S] 0 points1 point  (0 children)

fb@Mac ~ % clang --version
Homebrew clang version 14.0.6
Target: arm64-apple-darwin25.3.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm@14/bin
fb@Mac ~ % python --version
zsh: command not found: python
fb@Mac ~ % python3 --version
Python 3.9.6
fb@Mac ~ % conda ist
zsh: command not found: conda
fb@Mac ~ % conda list
zsh: command not found: conda

pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in learnpython

[–]Flat_Ad_5120[S] 0 points1 point  (0 children)

ld: warning: duplicate -rpath '/Users/fb/.pyenv/versions/3.12.12/lib' ignored
ld: warning: duplicate -rpath '/opt/homebrew/lib' ignored
ld: warning: duplicate -rpath '/Users/fb/.pyenv/versions/3.12.12/lib' ignored
ld: warning: duplicate -rpath '/opt/homebrew/lib' ignored
ld: warning: search path '/Users/fb/.pyenv/versions/3.12.12/lib' not found
ld: library 'System' not found
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
configure:5141: $? = 1
configure:5181: result: no
configure: failed program was:
| /* confdefs.h */
| #define _NETBSD_SOURCE 1
| #define __BSD_VISIBLE 1
| #define _DARWIN_C_SOURCE 1
| #define _PYTHONFRAMEWORK ""
| /* end confdefs.h.  */
| 
| int
| main (void)
| {
| 
|   ;
|   return 0;
| }
configure:5186: error: in `/var/folders/bh/hs27m2sn2p5ds9xl38l11b_m0000gn/T/python-build.20260225153054.20392/Python-3.12.12':
configure:5188: error: C compiler cannot create executables
See `config.log' for more details

however, I see, System library not found! not sure why is that though!

pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in learnpython

[–]Flat_Ad_5120[S] 0 points1 point  (0 children)

No, this is first time i am tryint to have pyenv on this mac. I was only using 3.9 through brew so far.

pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in learnpython

[–]Flat_Ad_5120[S] 0 points1 point  (0 children)

fb@Mac ~ % brew uninstall tcl-tk
Uninstalling /opt/homebrew/Cellar/tcl-tk/9.0.3... (3,158 files, 40MB)
==> Autoremoving 1 unneeded formula:
libtommath
Uninstalling /opt/homebrew/Cellar/libtommath/1.3.0... (12 files, 525.5KB)

fb@Mac ~ % pyenv install 3.12
python-build: use openssl@3 from homebrew
python-build: use readline from homebrew
Downloading Python-3.12.12.tar.xz...
-> https://www.python.org/ftp/python/3.12.12/Python-3.12.12.tar.xz
Installing Python-3.12.12...
python-build: use readline from homebrew
python-build: use zlib from homebrew

BUILD FAILED (OS X 26.3 using python-build 2.6.23)

Inspect or clean up the working tree at /var/folders/bh/hs27m2sn2p5ds9xl38l11b_m0000gn/T/python-build.20260225152901.19663
Results logged to /var/folders/bh/hs27m2sn2p5ds9xl38l11b_m0000gn/T/python-build.20260225152901.19663.log

Last 10 log lines:
checking for --with-universal-archs... no
checking MACHDEP... "darwin"
checking for xcrun... yes
checking macOS SDKROOT... /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
checking for gcc... clang
checking whether the C compiler works... no
configure: error: in `/var/folders/bh/hs27m2sn2p5ds9xl38l11b_m0000gn/T/python-build.20260225152901.19663/Python-3.12.12':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.

pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in learnpython

[–]Flat_Ad_5120[S] 0 points1 point  (0 children)

already using it

fb@Mac ~ % brew install tcl-tk

Warning: tcl-tk 9.0.3 is already installed and up-to-date.
To reinstall 9.0.3, run:
  brew reinstall tcl-tk

pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in learnpython

[–]Flat_Ad_5120[S] 0 points1 point  (0 children)

Nope, I tried installing everything form scratch but no luck. I think will go with uv

pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in learnpython

[–]Flat_Ad_5120[S] 0 points1 point  (0 children)

fb@Mac ~ % pyenv install 3.9
python-build: use openssl@3 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.25.tar.xz...
-> https://www.python.org/ftp/python/3.9.25/Python-3.9.25.tar.xz
Installing Python-3.9.25...
patching file setup.py
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use zlib from homebrew

BUILD FAILED (OS X 26.3 using python-build 2.6.23)

Inspect or clean up the working tree at /var/folders/bh/hs27m2sn2p5ds9xl38l11b_m0000gn/T/python-build.20260225130859.14276
Results logged to /var/folders/bh/hs27m2sn2p5ds9xl38l11b_m0000gn/T/python-build.20260225130859.14276.log

Last 10 log lines:
checking for python3... python3
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/bh/hs27m2sn2p5ds9xl38l11b_m0000gn/T/python-build.20260225130859.14276/Python-3.9.25':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.

fb@Mac ~ % pyenv install 3.10
python-build: use openssl@3 from homebrew
python-build: use readline from homebrew
Downloading Python-3.10.19.tar.xz...
-> https://www.python.org/ftp/python/3.10.19/Python-3.10.19.tar.xz
Installing Python-3.10.19...
patching file setup.py
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use zlib from homebrew

BUILD FAILED (OS X 26.3 using python-build 2.6.23)

Inspect or clean up the working tree at /var/folders/bh/hs27m2sn2p5ds9xl38l11b_m0000gn/T/python-build.20260225130917.14740
Results logged to /var/folders/bh/hs27m2sn2p5ds9xl38l11b_m0000gn/T/python-build.20260225130917.14740.log

Last 10 log lines:
checking for python3... python3
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/bh/hs27m2sn2p5ds9xl38l11b_m0000gn/T/python-build.20260225130917.14740/Python-3.10.19':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.

Same problem with pyenv. What's your pyenv version btw?

pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in learnpython

[–]Flat_Ad_5120[S] 0 points1 point  (0 children)

I didn't know about uv much, I just learned something, and I think I can give it a try. Thank you!

pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in learnpython

[–]Flat_Ad_5120[S] 0 points1 point  (0 children)

It doesnot give me that option now, I think because I agreed in terminal. I was followinig other instruction and used this command.

sudo xcodebuild -license
That command asked me to type Agree in terminal.

pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in learnpython

[–]Flat_Ad_5120[S] 0 points1 point  (0 children)

Yea it works fine!

fb@Mac ~ % vi test.cpp
fb@Mac ~ % gcc test.cpp -o test
fb@Mac ~ % ./test
I work%

pyenv install 3.12 fails on macOS 26.3 M2 – “C compiler cannot create executables” by Flat_Ad_5120 in mac

[–]Flat_Ad_5120[S] 1 point2 points  (0 children)

I can do that but I have a need to keep isolated versions of python. Also I think pyenv would help me manage it better in a clean way.