PyEnv BUILD FAILED installing Python on MacOS

y2k-shubham picture y2k-shubham · Jul 27, 2018 · Viewed 32k times · Source

While trying to install Python 3.6.6 (for Airflow) using PyEnv on MacOS, I am encountering build failure with following stack-trace

File
"/private/var/folders/6y/kf699bqj2sgcgjshb20fr5zh0000gn/T/python-build.20180721180716.86347/Python-3.6.6/Lib/xmlrpc/client.py",
line 138, in <module>
    from xml.parsers import expat   File "/private/var/folders/6y/kf699bqj2sgcgjshb20fr5zh0000gn/T/python-build.20180721180716.86347/Python-3.6.6/Lib/xml/parsers/expat.py",
line 4, in <module>
    from pyexpat import * ModuleNotFoundError: No module named 'pyexpat' make: *** [install] Error 1

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

Inspect or clean up the working tree at
/var/folders/6y/kf699bqj2sgcgjshb20fr5zh0000gn/T/python-build.20180721180716.86347
Results logged to /var/folders/6y/kf699bqj2sgcgjsh

I've followed the steps mentioned in the docs for setting-up PyEnv on Mac via Homebrew.


Environment / Framework versions

  • MacOS High Sierra 10.13.6
  • Homebrew 1.7.1
  • PyEnv 1.2.6
  • Existing Python distributions
    • Python 2.7.15 [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
    • Python 3.7.0 [Clang 9.0.0 (clang-900.0.39.2)] on darwin

Answer

Henrique Bastos picture Henrique Bastos · Jun 23, 2019

I had this problem with Mojave and Python 3.7.3.

This worked for me:

SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk MACOSX_DEPLOYMENT_TARGET=10.14 pyenv install 3.7.3