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
-> https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tar.xz
2
Installing Python-2.7.15...
3
python-build: use readline from homebrew
4
ERROR: The Python zlib extension was not compiled. Missing the zlib?
5
6
Please consult to the Wiki page to fix the problem.
7
https://github.com/pyenv/pyenv/wiki/Common-build-problems
8
9
10
BUILD FAILED (OS X 10.14 using python-build 1.2.7-11-g835707da)
11
12
Inspect or clean up the working tree at /var/folders/mk/y3g2kcsd52vcnr19q94wg2hm0000gn/T/python-build.20190426114725.37557
13
Results logged to /var/folders/mk/y3g2kcsd52vcnr19q94wg2hm0000gn/T/python-build.20190426114725.37557.log
14
15
Last 10 log lines:
16
rm -f /Users/maxhuang/.pyenv/versions/2.7.15/share/man/man1/python.1
17
(cd /Users/maxhuang/.pyenv/versions/2.7.15/share/man/man1; ln -s python2.1 python.1)
18
if test "xno" != "xno"  ; then \
19
        case no in \
20
            upgrade) ensurepip="--upgrade" ;; \
21
            install|*) ensurepip="" ;; \
22
        esac; \
23
         ./python.exe -E -m ensurepip \
24
            $ensurepip --root=/ ; \
25
    fi
26
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