fukudama
fukudama

Reputation: 2306

The Python zlib extension was not compiled on Mac OS X 10.11.1

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:

Upvotes: 4

Views: 11911

Answers (5)

dnlsur
dnlsur

Reputation: 11

When installing Python 2.7.18 in Mac M1 (Apple Silicon) with the new 'brew' version that works in '/opt/hombrew', not in '/usr/local/opt':

export LDFLAGS="-L/opt/homebrew/opt/zlib/lib"
export CPPFLAGS="-I/opt/homebrew/opt/zlib/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/zlib/lib/pkgconfig"

arch -x86_64 pyenv install 2.7.18

Upvotes: 1

Tiago G.
Tiago G.

Reputation: 139

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.

Upvotes: 7

bulletRush
bulletRush

Reputation: 124

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

brew reinstall pyenv

Upvotes: 0

MikeZhang
MikeZhang

Reputation: 337

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

Upvotes: 5

fukudama
fukudama

Reputation: 2306

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

Upvotes: 1

Related Questions