Developing software in the Real World

Cannot find zlib headers on macOS 10.15 Catalina

My new MacBook Pro 16″ comes with Catalina and while setting up Python to develop rst2pdf, I discovered that Pillow wouldn’t install.

Looking through the long list of red text I came across:


The way this was solved on the previous version of macOS (Mojave) was to use the macOS_SDK_headers_for_macOS_10.14.pkg installer to set up symlinks to header files from the old place to the new place.

This doesn’t work on Catalina, so we need to add the correct directory to the CPATH, but putting this in our .zshrc (or .bashrc if you upgraded from Mojave)

Restart your terminal and then Pillow along with any other package that requires zlib or other standard headers will now install.

Alternatively, if you’re a little lazy, you can try:

However, Homebrew or something similar may come along and clobber what you’ve done in the future.

9 thoughts on “Cannot find zlib headers on macOS 10.15 Catalina

  1. this fixed issue for me on catalina (you have xcode tool alread installed):
    sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/

  2. Brilliant, spent 1/2 day trying to get PIP installed on my Mac (catalina 10.15.5). This is what finally worked for me:
    sudo SLUGIFY_USES_TEXT_UNIDECODE=yes CPATH=xcrun --show-sdk-path/usr/include pip install -r ~/requirements.txt

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *