While trying to install Python 3.6.6 (for Airflow) using PyEnv on MacOS, I am encountering build failure
short answer:
$ brew upgrade
now you can try to install python through pyenv
$ pyenv install 3.7.4
then, you have to set the python path
pyenv global 3.7.4
now, close and open a new terminal and write the command
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
That's all. For me it was fine.
I was able to get away with above error by referring to Common build problems
brew install readline xzxcode-select --installbrew install opensslAfter this, I installed and initialized pyenv
brew install pyenvpyenv init (inside your project directory)Finally install and activate required python version
pyenv local 3.6.6 (inside your project directory)Here's the link to original thread #1188 on GitHub by @Harry Moreno
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
BUILD FAILED (OS X 10.14.3 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/kt/79hj2dxs5vg7gsy188n6tk9c0000gn/T/python-build.20190226112205.71745
Results logged to /var/folders/kt/79hj2dxs5vg7gsy188n6tk9c0000gn/T/python-build.20190226112205.71745.log
Last 10 log lines:
File "/private/var/folders/kt/79hj2dxs5vg7gsy188n6tk9c0000gn/T/python-build.20190226112205.71745/Python-3.6.6/Lib/ensurepip/__main__.py", line 5, in <module>
sys.exit(ensurepip._main())
File "/private/var/folders/kt/79hj2dxs5vg7gsy188n6tk9c0000gn/T/python-build.20190226112205.71745/Python-3.6.6/Lib/ensurepip/__init__.py", line 204, in _main
default_pip=args.default_pip,
File "/private/var/folders/kt/79hj2dxs5vg7gsy188n6tk9c0000gn/T/python-build.20190226112205.71745/Python-3.6.6/Lib/ensurepip/__init__.py", line 117, in _bootstrap
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/private/var/folders/kt/79hj2dxs5vg7gsy188n6tk9c0000gn/T/python-build.20190226112205.71745/Python-3.6.6/Lib/ensurepip/__init__.py", line 27, in _run_pip
import pip._internal
I found the solution from http://digidememory.blogspot.com/2019/01/macos-mojave-10142python371.html
In my case, I solved by this command
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
The accepted answer didn't work for me (Mojave) but this did:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
Credit to http://www.blog.howechen.com/macos-mojave-pyenv-install-multi-version-build-failed-solution/
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