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 appreciated
EDIT:
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
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…