Build pyenv Python versions on macOS Catalina 10.15

19 February 2020   4 comments   Python, MacOSX

https://github.com/pyenv/pyenv/issues/1348#issuecomment-588001367

I'm still working on getting pyenv in my bloodstream. It seems like totally the right tool for having different versions of Python available on macOS that don't suddenly break when you run brew upgrade periodically. But every thing I tried failed with an error similar to this:

python-build: use openssl from homebrew
python-build: use readline from homebrew
Installing Python-3.7.0...
python-build: use readline from homebrew

BUILD FAILED (OS X 10.15.x using python-build 20XXXXXX)

Inspect or clean up the working tree at /var/folders/mw/0ddksqyn4x18lbwftnc5dg0w0000gn/T/python-build.20190528163135.60751
Results logged to /var/folders/mw/0ddksqyn4x18lbwftnc5dg0w0000gn/T/python-build.20190528163135.60751.log

Last 10 log lines:
./Modules/posixmodule.c:5924:9: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0)
        ^
./Modules/posixmodule.c:6018:11: error: implicit declaration of function 'forkpty' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    pid = forkpty(&master_fd, NULL, NULL, NULL);
          ^
./Modules/posixmodule.c:6018:11: warning: this function declaration is not a prototype [-Wstrict-prototypes]
2 warnings and 2 errors generated.
make: *** [Modules/posixmodule.o] Error 1
make: *** Waiting for unfinished jobs....

I read through the Troubleshooting FAQ and the "Common build problems" documentation. xcode was up to date and I had all the related brew packages upgraded. Nothing seemed to work.

Until I saw this comment on an open pyenv issue: "Unable to install any Python version on MacOS"

All I had to do was replace the 10.14 for 10.15 and now it finally worked here on Catalina 10.15. So, the magical line was this:

SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk \
MACOSX_DEPLOYMENT_TARGET=10.15 \
PYTHON_CONFIGURE_OPTS="--enable-framework" \
pyenv install -v 3.7.6

Hopefully, by blogging about it you'll find this from Googling and I'll remember the next time I need it because it did eat 2 hours of precious evening coding time.

Comments

Peter Hastings

You are awesome! I was getting nowhere, and that was exactly the solution I needed.

john

Seconding Peter's comment!

Miguel Garcia

Thank you for this post! It saved me a lot of time!

Denis Arnaud

Thanks for the contribution!
On the new MacOS version (11.0 aka Big Sur), the command line becomes:
SKDROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk \
MACOSX_DEPLOYMENT_TARGET=11.0 \
PYTHON_CONFIGURE_OPTS="--enable-framework" \
pyenv install 3.7.6

But then another error comes up:
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.5.10.tar.xz...
-> https://www.python.org/ftp/python/3.5.10/Python-3.5.10.tar.xz
Installing Python-3.5.10...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 11.0.1 using python-build 1.2.21-1-g943015eb)

Inspect or clean up the working tree at /var/folders/hg/fcmc5nwj43dg2p_cp6gc4rmr0000gn/T/python-build.20201116231208.85510
Results logged to /var/folders/hg/fcmc5nwj43dg2p_cp6gc4rmr0000gn/T/python-build.20201116231208.85510.log

Last 10 log lines:
        posix_error();
        ^~~~~~~~~~~
4 warnings generated.
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -Werror=declaration-after-statement -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/darnaud/.pyenv/versions/3.5.10/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/darnaud/.pyenv/versions/3.5.10/include -DPy_BUILD_CORE -c ./Modules/_sre.c -o Modules/_sre.o
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -Werror=declaration-after-statement -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/darnaud/.pyenv/versions/3.5.10/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/darnaud/.pyenv/versions/3.5.10/include -DPy_BUILD_CORE -c ./Modules/_codecsmodule.c -o Modules/_codecsmodule.o
11 warnings and 1 error generated.
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -Werror=declaration-after-statement -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/darnaud/.pyenv/versions/3.5.10/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/darnaud/.pyenv/versions/3.5.10/include -DPy_BUILD_CORE -c ./Modules/_weakref.c -o Modules/_weakref.o
make: *** [Modules/posixmodule.o] Error 1
make: *** Waiting for unfinished jobs....
1 warning generated.

Your email will never ever be published

Related posts