Gangmax Blog

The Error When Installing Python 2.7.15 under MacOS 10.14

I need a Python 2.7.15 environment to run something on my Mac(MacOS 10.14). So I run:

1
pyenv install 2.7.15

But I gett the following error:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-> https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tar.xz
Installing Python-2.7.15...
python-build: use readline from homebrew
ERROR: The Python zlib extension was not compiled. Missing the zlib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (OS X 10.14 using python-build 1.2.7-11-g835707da)

Inspect or clean up the working tree at /var/folders/mk/y3g2kcsd52vcnr19q94wg2hm0000gn/T/python-build.20190426114725.37557
Results logged to /var/folders/mk/y3g2kcsd52vcnr19q94wg2hm0000gn/T/python-build.20190426114725.37557.log

Last 10 log lines:
rm -f /Users/maxhuang/.pyenv/versions/2.7.15/share/man/man1/python.1
(cd /Users/maxhuang/.pyenv/versions/2.7.15/share/man/man1; ln -s python2.1 python.1)
if test "xno" != "xno" ; then \
case no in \
upgrade) ensurepip="--upgrade" ;; \
install|*) ensurepip="" ;; \
esac; \
./python.exe -E -m ensurepip \
$ensurepip --root=/ ; \
fi
exit 1

“brew install zlib” doesn’t fix the issue.

Google the problem and get a solution from here, run the following command:

1
CPPFLAGS="-I$(brew --prefix zlib)/include" pyenv install 2.7.15

The issue is solved.

Comments