pyenv configure: error: C compiler cannot create executables

We Are Going To Discuss About pyenv configure: error: C compiler cannot create executables. So lets Start this Python Article.

pyenv configure: error: C compiler cannot create executables

  1. How to solve pyenv configure: error: C compiler cannot create executables

    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/.

  2. pyenv configure: error: C compiler cannot create executables

    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 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/.

Original Author carter Of This Content

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:

Original Author nenetto Of This Content

Solution 3

I used the following and it worked

CC=gcc pyenv install 3.7.10

Original Author Max Bregman Of This Content

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.

Original Author A Avinash Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment