MRalwasser
MRalwasser

Reputation: 15973

cygwin: pillow cannot find libjpeg

Installing pillow 8.x/9.0 on cygwin currently fails. It finds the jpeglib.h, but not the library (which exists, libjpeg-devel is installed):

$ ls -l /usr/include/jpeglib.h  /usr/lib/libjpeg.dll.a
-rw-r--r-- 1 user group 50281 Nov 19 04:04 /usr/include/jpeglib.h
-rwxr-xr-x 1 user group 83496 Nov 23 01:10 /usr/lib/libjpeg.dll.a

setup.py output (with debugging enabled):

Looking for jpeg
Checking for include file jpeglib.h in /tmp/pip-install-22fl1qzk/pillow_ff8a20e272ec40ee831aa9c1f2d606fd
Checking for include file jpeglib.h in /usr/include
Found jpeglib.h
Couldn't find library jpeg in ['/tmp/pip-install-22fl1qzk/pillow_ff8a20e272ec40ee831aa9c1f2d606fd', '/usr/lib', '/usr/local/lib', '/lib', '/usr/lib/python3.9/config', '/usr/lib']

[...]

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

Please see the install instructions at:
   https://pillow.readthedocs.io/en/latest/installation.html

Traceback (most recent call last):
  File "/tmp/pip-install-22fl1qzk/pillow_ff8a20e272ec40ee831aa9c1f2d606fd/setup.py", line 989, in <module>
    setup(
  File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 155, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 148, in setup
    return run_commands(dist)
  File "/usr/local/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 163, in run_commands
    dist.run_commands()
  File "/usr/local/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 967, in run_commands
    self.run_command(cmd)
  File "/usr/local/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 79, in run
    _build_ext.run(self)
  File "/usr/local/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/tmp/pip-install-22fl1qzk/pillow_ff8a20e272ec40ee831aa9c1f2d606fd/setup.py", line 804, in build_extensions
    raise RequiredDependencyException(f)
__main__.RequiredDependencyException: jpeg

How can I resolve this issue?

Upvotes: 0

Views: 313

Answers (2)

Ryan M
Ryan M

Reputation: 11

Not sure this is the best solution but I was having the same problem (Installing Pillow 9.1 on cygwin and using Python3.8) and it worked for me. The Pillow documentation (https://pillow.readthedocs.io/en/stable/installation.html) suggests editing setup.py if the libraries are not installed in standard locations. I think maybe the file location is correct in this instance but maybe the extension is unexpected. Regardless:

"If the prerequisites are installed in the standard library locations for your machine (e.g. /usr or /usr/local), no additional configuration should be required. If they are installed in a non-standard location, you may need to configure setuptools to use those locations by editing setup.py or setup.cfg, or by adding environment variables on the command line:"

So I edited setup.py to return the correct path for libjpeg.dll.a where searching for the jpeg library (more specifically i edited the _find_library_file function to return the exact path when searching for the libjpeg library). I then installed using pip and the setup ran successfully.

Upvotes: 1

matzeri
matzeri

Reputation: 8496

Pillow is already available on Cygwin, It is just named imaging

$ cygcheck -cd |grep imaging
python36-imaging                           8.4.0-1
python36-imaging-tk                        8.4.0-1
python37-imaging                           8.4.0-1
python37-imaging-tk                        8.4.0-1
python38-imaging                           8.4.0-1
python38-imaging-tk                        8.4.0-1
python39-imaging                           8.4.0-1
python39-imaging-tk                        8.4.0-1

Upvotes: 0

Related Questions