Open glitchyordis opened 2 years ago
Please follow the installation instructions at https://github.com/uploadcare/pillow-simd#installation especially the bit about prerequisites.
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!
In case it's helpful for others, I had the same problem and realised it was due to the following call to ldconfig -p in setup.py, which was silently failing when I tried to run as non root on Debian bullseye:
try:
p = subprocess.Popen(
args, stderr=subprocess.DEVNULL, stdout=subprocess.PIPE, env=env
)
except OSError: # E.g. command not found
return []
i.e.
$ ldconfig -p
zsh: command not found: ldconfig
$ sudo ldconfig -p
721 libs found in cache `/etc/ld.so.cache'
libz3.so.4 (libc6,x86-64) => /lib/x86_64-linux-gnu/libz3.so.4
libzvbi.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libzvbi.so.0
libzvbi-chains.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libzvbi-chains.so.0
...
I'll raise an issue with upstream as it would be nice to make this failing call emit something in the logs to make this more debuggable.
Actually maybe it's this missing commit from upstream: https://github.com/python-pillow/Pillow/commit/ca2bf046d35ec41251716cac152fc9209964a359
Yep, I can config /sbin/ldconfig -p
runs ok without sudo, but ldconfig -p
does not.
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?