Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyenv won't install python 3 on Mac os 11

Tags:

pyenv

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.

like image 804
jasonm Avatar asked Nov 14 '20 23:11

jasonm


1 Answers

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.

like image 165
Cornelius Avatar answered Oct 21 '22 14:10

Cornelius