pyenv configure: error: C compiler cannot create executables
Solution 1
This worked for me: I removed the command line tools as root and reinstalled ...
Your Command Line Tools (CLT) does not support macOS 11. It is either outdated or was modified. Please update your Command Line Tools (CLT) or delete it if no updates are 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/more/.
Solution 2
Seems there is a problem with Xcode, zlib and compiler options. From brew they made some patches to 3.8.0 python version.
My configuration
$ sw_vers
ProductName: macOS
ProductVersion: 11.2.3
BuildVersion: 20D91
$ clang --version
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
This worked for me to install 3.8.3 and 3.9.0
# Re-install Xcode
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
# Install zlib and bzip2 using brew
brew reinstall zlib bzip2
# Install tcl-tk tkinter
brew install tcl-tk
# Uninstall previous versions from python
pyenv uninstall 3.8.3
pyenv uninstall 3.9.0
# Install python 3.8.3 patched
env \
PATH="$(brew --prefix tcl-tk)/bin:$PATH" \
LDFLAGS="-L$(brew --prefix tcl-tk)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" \
CPPFLAGS="-I$(brew --prefix tcl-tk)/include -L$(brew --prefix zlib)/include -L$(brew --prefix bzip2)/include" \
PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
CFLAGS="-I$(brew --prefix tcl-tk)/include -I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix zlib)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" \
LDFLAGS="-I$(brew --prefix tcl-tk)/lib -L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib"
pyenv install --patch 3.8.3 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
env \
PATH="$(brew --prefix tcl-tk)/bin:$PATH" \
LDFLAGS="-L$(brew --prefix tcl-tk)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" \
CPPFLAGS="-I$(brew --prefix tcl-tk)/include -L$(brew --prefix zlib)/include -L$(brew --prefix bzip2)/include" \
PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
CFLAGS="-I$(brew --prefix tcl-tk)/include -I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix zlib)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" \
LDFLAGS="-I$(brew --prefix tcl-tk)/lib -L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib"
pyenv install 3.9.0
My sources where I did come up with the solution:
- pyenv configure: error: C compiler cannot create executables
- unable to install python 3.8.0 on macox 11 #1740
- Unable to build Python on macOS Big Sur with Xcode 12 beta #1643
Solution 3
I used the following and it worked
CC=gcc pyenv install 3.7.10
Solution 4
It got fixed with yesterdays release. attaching the git closed issue here
in a nutshell pyenv python versions of 3.7.13, 3.8.13, 3.9.11 and 3.10.3 will work fine from now on.
jesse fredrickson
Updated on June 18, 2022Comments
-
jesse fredrickson over 1 year
I am trying to install multiple versions of Python on my laptop running MacOS Big Sur v11.1. I initially installed xcode command line tools, homebrew, and python via instructions here
xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install python
But later on involuntarily upgraded python to 3.9, and I need to go back to 3.7.9. So I installed pyenv and attempted to install python 3.7.9 per instructions here
brew install pyenv
pyenv install 3.7.9
But I encountered the following error:
/var/folders/8n/ml0qwc091w9bhpszzxy9djl00000gn/T/python-build.20210118111111.56108 /usr/local/Cellar /var/folders/8n/ml0qwc091w9bhpszzxy9djl00000gn/T/python-build.20210118111111.56108/Python-3.7.9 /var/folders/8n/ml0qwc091w9bhpszzxy9djl00000gn/T/python-build.20210118111111.56108 /usr/local/Cellar checking build system type... x86_64-apple-darwin20.2.0 checking host system type... x86_64-apple-darwin20.2.0 checking for python3.7... no checking for python3... python3 checking for --enable-universalsdk... no checking for --with-universal-archs... no checking MACHDEP... checking for --without-gcc... no checking for --with-icc... no checking for gcc... clang checking whether the C compiler works... no configure: error: in `/var/folders/8n/ml0qwc091w9bhpszzxy9djl00000gn/T/python-build.20210118111111.56108/Python-3.7.9': configure: error: C compiler cannot create executables See `config.log' for more details make: *** No targets specified and no makefile found. Stop.
From other answers online it seems my gcc may be out of date. I checked my gcc version with
[/usr/local/Cellar]$ gcc --version Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1 Apple clang version 11.0.3 (clang-1103.0.32.62) Target: x86_64-apple-darwin20.2.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Which seems to indicate I am on version 4.2.1. I have not been able to find a way to update it on my own yet, but did
brew install gcc
which did not resolve the problem. Any help would be much appreciatedEDIT: Seems pyenv is using clang and not gcc. Perhaps xcode-select installed both?
clang --version
returns:Apple clang version 11.0.3 (clang-1103.0.32.62) Target: x86_64-apple-darwin20.2.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin
-
ForceBru almost 3 years"involuntarily upgraded python to 3.9, and I need to go back to 3.7.9" - doesn't
brew
provide any functionality to install the exact version you need? See e.g. stackoverflow.com/questions/3987683/… -
jesse fredrickson almost 3 yearsYes, I can
brew install [email protected]
(and I have). However I have not been able tobrew switch python 3.7
, andbrew info python
only shows @3.9 installed for some reason.ll /usr/local/Cellar | grep python
shows [email protected] and [email protected] -
jesse fredrickson almost 3 yearsI'm also wary that going this route - using homebrew to manage multiple python installations - might be trickier than using pyenv.
-
-
John Conery over 2 yearsI removed my old version with rm, ran the install command to reinstall, everything is OK now. Thanks!
-
Piotr BG over 2 yearsReinstalling xcode-select (and rebooting) worked for me
-
Alexander Hamilton about 2 yearsThank you so much.
-
Daniel Kobe almost 2 yearsI had to do this stackoverflow.com/a/47725718/4885784
-
Armstrongya almost 2 yearsThanks for your help, delete CommandLineTools and re-install it works.
-
Fuligo septica almost 2 yearsRemoved the old command line tools and reinstalled per your instructions. Problem solved. Thanks!
-
Mote Zart over 1 yearCould be a helpful answer but not without more detail. Like, which command line tools?
-
starmandeluxe over 1 yearDidn't work at all. Error still shows for me.