Pyenv won't install python 3 on Mac os 11
Asked Answered
T

7

24

Trying to install Python 3.9.0 on Mac OS 11.0.1 with pyenv install 3.9.0.

Results:

python-build: use readline from homebrew
Downloading Python-3.9.0.tar.xz...
-> https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
Installing Python-3.9.0...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 11.0.1 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/n6/q2b78971589bltfczw539flh0000gn/T/python-build.20201114175722.7103
Results logged to /var/folders/n6/q2b78971589bltfczw539flh0000gn/T/python-build.20201114175722.7103.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/n6/q2b78971589bltfczw539flh0000gn/T/python-build.20201114175722.7103/Python-3.9.0':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.

Many suggestions in similar questions seem to revolve around XCode, but xcode-select --install says command line tools already installed.

Any help appreciated.

Throstle answered 14/11, 2020 at 23:2 Comment(0)
E
23

I ran into the same issue today and managed to get one step further after diving into the config.log and checking this post here.

I had to take the opposite direction and execute sudo xcode-select --switch /Applications/Xcode.app/ after downloading Xcode from the App Store. If you run clang --version it should show Apple clang version 12.0.0 (clang-1200.0.32.27).

I was able to execute pyenv install 3.9.0 and get past the C compiler cannot create executables error, but unfortunately it still failed. config.log is huge this time around, will see if I can find anything.

EDIT: I managed to install 3.8.0 by executing the following command including a patch found here.

CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-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.0 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)

There have been some macOS 11.0 merges, but I assume the repos used for the pyenv install command are simply not yet updated. This workaround will suffice for my needs for now, however.

Eanes answered 15/11, 2020 at 17:11 Comment(1)
Thank you, that worked beautifully. I did note that for 3.7 I needed the patch, while for 3.9 I did not (it was enough with all the flags).Hastie
F
2

Check where your clang is located:

which clang

It should be somewhere under /usr/bin/clang. In my case from old times it was coming from Miniconda that was put artificially on the command line PATH. Fix that so that clang comes from Xcode and that should bring you forward with Python on Mac installation.

Fubsy answered 26/1, 2021 at 23:8 Comment(1)
THIS! As trivial as it is, it was the cause in my case.Aragon
D
2

I've successfully installed python 3.6.13 on the m1 macbook with this command.

CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.6.13 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
Deadly answered 18/2, 2021 at 15:13 Comment(0)
H
0

Ran into the same issue that OP posted after following these enter link description here to install Python 3.9.6.

Here are the specs to my environment:

MacOS 11.4 (Big Sur)
XCode 12.5.1

To get past this issue, I had to:

  1. Update the Command Line Tools to XCode to 12.5.1 (I had mistakenly thought that the Command Line Tools version was 12.5.1 just because my XCode version was 12.5.1)

  2. Install python: pyenv install 3.9.6

There was no need to install the patch mentioned in @Cornelius' answer.

My solution was adapted from here.

Heparin answered 19/7, 2021 at 20:26 Comment(0)
C
0

I had a similar situation trying to install python versions using pyenv on my outdated MacOS.

configure: error: C compiler cannot create executables.

I had tried the following:

  • Updated to MacOS 12.1 (Monterey)
  • Updated the Command Line Tools via xcode-select --install
  • Updated Brew & Pyenv

While I am sure these were necessary steps, I continued to get the error until I also updated Xcode. It was such an outdated version it was no longer compatible with MacOS 12.1. I believe this was the main issue since it seems the Clang compiler from Xcode is used by default. Upgrading Xcode to 13.2 (latest at time of writing) did the trick.

Caesaria answered 16/12, 2021 at 17:45 Comment(0)
C
0

Did you already try this:

pyenv install --patch 3.8.6 <<(curl -sSL https://raw.githubusercontent.com/Homebrew/formula-patches/113aa84/python/3.8.3.patch\?full_index\=1)

like was related here: https://github.com/pyenv/pyenv/issues/1768#issuecomment-753756051

If you having the same problem after running the code above try:

softwareupdate --all --install --force
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

like was related here: https://github.com/pyenv/pyenv/issues/2201#issuecomment-1001597344

Them:

https://raw.githubusercontent.com/Homebrew/formula-patches/113aa84/python/3.8.3.patch\?full_index\=1)

This is how I solved it on my Macbook air M1.

Creditable answered 17/3, 2022 at 19:52 Comment(0)
P
0

I had the same error ("no makefile found") on macOS Montery 12.4, XCode 13.4.1, while attempting to install Python 3.9.10, despite also having xcode command line tools installed.

What fixed it for me was to open XCode, open Preferences -> Locations and then to select a valid version of Command Line Tools (this required entering admin credentials). There was no selection at all when I opened the window, so I suspect it was somehow unset at some XCode/macOS update.

After making the selection, the installation worked with pyenv install 3.9.10.

Pomona answered 3/8, 2022 at 8:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.