Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"headers or library files could not be found for zlib" #120

Open
glitchyordis opened this issue Aug 20, 2022 · 2 comments
Open

"headers or library files could not be found for zlib" #120

glitchyordis opened this issue Aug 20, 2022 · 2 comments

Comments

@glitchyordis
Copy link

glitchyordis commented Aug 20, 2022

What did you do?

python -m pip install --upgrade pip
python -m pip install Pillow-SIMD

I can always install Pillow without issue, the error on zlib only popups with Pillow-SIMD installation.

What did you expect to happen?

Successful installation of Pillow-SIMD.

What actually happened?

"The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source."

What are your OS, Python and Pillow versions?

  • OS: Windows 10, i7 core capable of SSE4
  • Python: 3.9.12
  • Pillow: I'v uninstalled this before installing Pillow SIMD
python -m pip uninstall -y pillow
python -m pip install --upgrade pip
python -m pip install Pillow-SIMD


pip uninstall -y pillow
pip install --upgrade pip
pip install Pillow-SIMD

image

@hugovk
Copy link

hugovk commented Aug 20, 2022

Please follow the installation instructions at https://github.com/uploadcare/pillow-simd#installation especially the bit about prerequisites.

@barretts
Copy link

barretts commented Apr 30, 2024

Windows 11
miniconda3: 24.3.0
Python: 3.10.11

Unlike the @glitchyordis I've never been able to install Pillow. I had the same error "headers or library files could not be found for zlib" and no amount of reinstalling of pip did it for me. This little resolution story was how I cobbled mine together. Everyone said "python comes with zlib" or "reinstall pip" but none of it solved the error. I am using Windows 11. I have Visual Studio 2022 installed.

My solution starts with running pip install of pillow-simd with the --no-clean option so that the temp folder is left behind.
python -m pip install --upgrade --no-clean Pillow-SIMD==9.0.0.post1

Which left all the temp files for me to use. Mine ended up in:
$env:LOCALAPPDATA\Temp\pip-install-_rwbjooc\pillow-simd_3565d826dd79413698dc3519a76e6564

From that folder edit the winbuild\build_perpare.py file to modify the zlib JSON config. I also had to modify libjpeg. At the time of this writing the file had a folder of version zlib-1.3.1 that came out. My modificaiton for libjpeg was just a URL change to use the prefix https://sourceforge.net/projects.

    "zlib": {
        "url": "https://zlib.net/current/zlib.tar.gz",
        "filename": "zlib.tar.gz",
        "dir": "zlib-1.3.1",
        "build": [
            cmd_nmake(r"win32\Makefile.msc", "clean"),
            cmd_nmake(r"win32\Makefile.msc", "zlib.lib"),
            cmd_copy("zlib.lib", "z.lib"),
        ],
        "headers": [r"z*.h"],
        "libs": [r"*.lib"],
    },

Running build_prepare.py now creates a build subfolder with a bunch of cmd files.
$env:LOCALAPPDATA\Temp\pip-install-_rwbjooc\pillow-simd_3565d826dd79413698dc3519a76e6564\winbuild\build

Here I ran build_dep_zlib.cmd and it built zlib and dropped the output into subfolders inc and lib.

I copied the files from inc to my $env:USERPROFILE\miniconda3\includes folder and the files from lib to $env:USERPROFILE\miniconda3\Lib.

Then running python -m pip install --upgrade Pillow-SIMD==9.0.0.post1 again worked. (Well for me it failed on libjpeg and I fixed it the same way)

Fair warning this is from memory / command history but probably has enough to get you moving forward. This was my system and my folders and in no way represents what you're working with. I hope this helps the next person!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants