Pillow installation PyPy3 missing zlib

Viewed 2911

I'm curretnly trying to use PIL with PyPy3, but no matter how I try to install it I get an error. First I tried to install it normally using pypy3 pip install pillow, but got the error that I need zlib. So after searching for a solution for a while I found the easy_install pillow command which fixed this problem for most people, but for me it leads to the same error. I hope somebody can help me out.

Error:

File "C:\Users\name\AppData\Local\Temp\easy_install-uqrsyszz\Pillow-4.0.0\setup.py", line 791, in <module> setuptools.sandbox.UnpickleableException: RequiredDependencyException('\n\nThe headers or library files could not be found for zlib,\na required dependency when compiling Pillow from source.\n\nPlease see the install instructions at:\n   http://pillow.readthedocs.io/en/latest/installation.html\n\n')
3 Answers

got it fixed by using pypy3 install pillow --global-option="build_ext" --global-option="--disable-zlib" --global-option="--disable-jpeg". :)

I was having a similar issue. After some research, I found this solution which got me most of the way there. I had to perform step #4 below in addition to get it to work for me:

  1. Install homebrew (if you don't already have it): /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Brew install zlib:

brew install zlib

  1. Set the following variables:

export LDFLAGS="-L/usr/local/opt/zlib/lib"

export CPPFLAGS="-I/usr/local/opt/zlib/include"

  1. Brew install jpeg

brew install jpeg

  1. Finally, pip install Pillow:

pip3 install Pillow==7.1.2

For linux debian based systems, the below solves the issue.

sudo apt install libjpeg-dev zlib1g zlib1g-dev
Related