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
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
pyenv is a wonderful tool for managing multiple Python versions. Even if you already have Python installed on your system, it is worth having pyenv installed so that you can easily try out new language features or help contribute to a project that is on a different version of Python.
python-build is a pyenv plugin that provides a pyenv install command to compile and install different versions of Python on UNIX-like systems. You can also use python-build without pyenv in environments where you need precise control over Python version installation.
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
The only way I could get it working is through the below prefixes before installing
CFLAGS="-I$(brew --prefix readline)/include -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" \ LDFLAGS="-L$(brew --prefix readline)/lib -L$(brew --prefix openssl)/lib" \ PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs2 \ pyenv install -v 3.7.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With