3

The following build error occurred when I build Python 2.7.11.

ERROR: The Python zlib extension was not compiled. Missing the zlib?

My Build environment is:

  • Mac OS X 10.11.1
  • Python 2.7.11

4 Answers 4

5

You should check here: https://github.com/yyuu/pyenv/wiki/Common-build-problems. Try to reinstall your command line tools.

5

I went through the same issue and what did the trick for me was:

  1. (Re)install zlib:
$ brew reinstall zlib
  1. Set its path to some env vars so compilers and pkg-config can find zlib:
$ export LDFLAGS="-L/usr/local/opt/zlib/lib"
$ export CPPFLAGS="-I/usr/local/opt/zlib/include"
$ export PKG_CONFIG_PATH="/usr/local/opt/zlib/lib/pkgconfig"
  1. Build Python again.
2
  • There's no need to install a second copy of zlib in macOS, and it may just confuse things down the line. Instead just point to the zlib that's already there and maintained by Apple. xcrun --show-sdk-path gives the path in which you will find usr/include and usr/lib.
    – Mark Adler
    Oct 12, 2022 at 14:53
  • What do the -L and -I stand for?
    – Y. Gherbi
    Nov 21, 2022 at 15:21
1

I found the great answer.

Run below command in the terminal to install the command line developer tools.

xcode-select --install

https://github.com/Homebrew/homebrew-python/issues/234

0
0

if you update to new mac os version, you may need upgrade pyenv first.

brew reinstall pyenv

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.