macOS Mojave pyenv: Install failed, "zlib not available"


Solution 1 to zlib error when compiling python

You will need to install SDK headers of xcode, you can find the installer at:


After installation executive the following command:

xcode select -s /Library/Developer/CommandLineTools

Solution 2: to "zlib not available"

When you try to install python using pyenv and you get the error:

zlib not available

Try to install python using the following CFLAGS:

CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install 2.7.16