Error when building mac python environment

I summarized it because it was difficult to find out how to deal with the error that occurred when building the python environment on mac.

I entered the following command in the terminal when installing python.

$ pyenv install 3.9.1

Then, the following error appeared.

Last 10 log lines:
checking for python3.9... python3.9
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/9y/b18s20496nz6mc47pmf2czdm0000gn/T/python-build.20210117143950.2739/Python-3.9.1':
configure: error: C compiler cannot create executables
See `config.log' for more details
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

It was solved by installing gcc (Command Line Tools of Xcode).

  1. Open Xcode and open the upper left (next to the apple mark) Xcode tab> Open Developer Tools> More Developer Tools ...

  2. Log in with your Xcode apple ID

  3. Download Command Line Tools for Xcode 12.0.dmg (any version)

  4. Installation

  5. Confirmation of installation

gcc -dumpversion   
12.0.0

After performing the above operations, the error disappeared and python was installed.

pyenv install 3.9.1
python-build: use [email protected] from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.1.tar.xz...
-> https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tar.xz
Installing Python-3.9.1...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.9.1 to /Users/shogo/.pyenv/versions/3.9.1



Recommended Posts

Error when building mac python environment
Building a Python environment on Mac
[Python] Building an environment with Anaconda [Mac]
[Mac] Building a virtual environment for Python
Mac environment construction Python
Building an environment for executing Python scripts (for mac)
Think about building a Python 3 environment in a Mac environment
Python environment construction For Mac
Building a Python virtual environment
Error when playing with python
Building a Python virtual environment
Building a Python environment for programming beginners (Mac OS)
[python] Error when installing library ramkan
Building a Python environment on Ubuntu
Building a Python environment on a Mac and using Jupyter lab
Create a Python environment on Mac (2017/4)
I checked Mac Python environment construction
Python environment construction memo on Mac
Building a virtual environment with Python 3
Environment construction of python3.8 on mac
Python3 TensorFlow for Mac environment construction
Precautions that must be understood when building a PYTHON environment
Error and solution when installing python3 with homebrew on mac (catalina 10.15)
Django Crispy Tutorial (Environment Building on Mac)
Building a Python3 environment with Amazon Linux2
Create ScriptableObject in Python when building ADX2
Solution for pip install error [Python] [Mac]
Note when creating an environment with python
Create a python environment on your Mac
Creating amateur python environment settings (for MAC)
Building a Python 3.6 environment with Windows + PowerShell
How to prepare Python development environment [Mac]
Notes on building Python and pyenv on Mac
Build Python environment with Anaconda on Mac
Error, warning when using TensorFlow on Mac
Building a Python development environment for AI development
When Python "Syntax Error: Non-ASCII character ~" appears
Things to watch out for when creating a Python environment on a Mac
Python environment construction
python environment settings
python windows environment
[Definitive Edition] Building an environment for learning "machine learning" using Python on Mac
Environment construction (python)
Python Error Handling
python on mac
python environment construction
Python --Environment construction
Python environment construction
[Django] sqlite version error when running python manage.py in aws cloud9 environment
python environment construction
Error when installing a module with Python pip
Python3 TensorFlow environment construction (Mac and pyenv virtualenv)
Building a python environment with virtualenv and direnv
Building an environment that uses Python in Eclipse
Python explosive environment construction starting from zero (Mac)
Building an Anaconda environment for Python with pyenv
Building a Python environment with WLS2 + Anaconda + PyCharm
Build a Python environment on Mac (Mountain Lion)
Building an environment for matplotlib + cartopy on Mac
Build a Python development environment on your Mac
[Python] Web development preparation (building a virtual environment)