15

I am trying to install the Python Pillow library and I am getting the following error:

ValueError: zlib is required unless explicitly disabled using --disable-zlib, aborting

I followed the thread to try to fix it: Fail during installation of Pillow (Python module) in Linux

The problem is that it seems to still not be able to find zlib, which I installed via homebrew.

I did a check to see if it was installed:

> brew search zlib
homebrew/dupes/zlib ✔                                        lzlib

I noticed it is in a different location than a standard brew install ("homebrew/dupes/zlib"). I tried to do an uninstall/reinstall and it puts it back in the same place ("homebrew/dupes/zlib"). The problem seems to be the installer/compiler just can't find it in that location.

My question is, Is there a way to either alias the lib path, point the installer to this lib location or clear it out completely from home-brew to re-install it clean just as zlib? What is the best route to take on this?

Thanks, RB

1
  • How exactly are you installing it? You should be using pip install pillow Commented Apr 12, 2016 at 4:33

5 Answers 5

17

I figured out how to handle this. I had to set the following flag, via an environment variable, ahead of the pip install to make sure it used the correct zlib path when compiling pillow.

CFLAGS="-I/usr/local/opt/zlib/include" pip install pillow

This worked.

2
  • Works. thanks. Surprised, why its not already in the include path. Commented Dec 5, 2016 at 4:13
  • Thank you. you saved my time.
    – blurfx
    Commented Jun 16, 2020 at 15:11
10

I had the same situation (Homebrew zlib in /usr/local/opt/zlib) but setting CFLAGS=… didn't fix the error.

xcode-select --install worked.

1
  • 1
    Thanks, I always forget to do this after OS upgrades. :) Commented Oct 4, 2016 at 21:59
7

I simply installed the jpeg lib in MacOSX Yosemite

brew install jpeg

Thereafter

pip install pillow

This worked nicely! ;)

0
2

If you are on MacOSX and installed zlib with brew, then try

brew link zlib --force

It worked for me Link: Fail during installation of Pillow (Python module) in Linux

1

None of the solutions given so far worked for me (OS X ElCapitan). Here is what worked:

brew tap homebrew/dupes
brew install zlib
brew install jpeg

The problem is zlib is not available in default Homebrew anymore. The lzlib that it prompts you to install instead does not work.

You can find detailed answer here: Fail during installation of Pillow (Python module) in Linux

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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