Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Pillow not installing under OSX

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

like image 989
renderbox Avatar asked Apr 12 '16 04:04

renderbox


People also ask

How do I install Pillow for Python?

The simplest way to install Pillow in PyCharm is to open the terminal tab and run the pip install Pillow command .

How do I install Python 3.8 Pillow?

Go to your windows command prompt (by going to the start menu and typing 'cmd') and type "pip install pillow". If that doesn't work, try "pip3 install pillow".

How do you check Pillow is installed or not?

To check which version of the Python library pillow is installed, run pip show pillow or pip3 show pillow in your CMD/Powershell (Windows), or terminal (macOS/Linux/Ubuntu).


2 Answers

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.

like image 118
renderbox Avatar answered Nov 09 '22 02:11

renderbox


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

xcode-select --install worked.

like image 24
sam Avatar answered Nov 09 '22 01:11

sam