python-pillow / Pillow

Python Imaging Library (Fork)
https://python-pillow.org
Other
12.35k stars 2.24k forks source link

Failing to load Image from PIL in macOS with 9.4.0 #6862

Closed jbeghtol closed 1 year ago

jbeghtol commented 1 year ago

We are currently using PIL on macOS inside a VENV to limit packaged. Today when we updated to 9.4.0 PIL stopped working on MacOS (these are x86_64 versions).

Steps to reproduce:

  1. setup venv (this was seen in python 3.9.4, 3.9.6, and also a 3.8.x version I don't recall)
  2. pip install Pillow
  3. python, from PIL import Image

(note, some parts of the path were trimmed)

python3
> from PIL import Image
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".venv/lib/python3.9/site-packages/PIL/Image.py", line 103, in <module>
    from . import _imaging as core
ImportError: dlopen(.venv/lib/python3.9/site-packages/PIL/_imaging.cpython-39-darwin.so, 2): Library not loaded: @loader_path/libXdmcp.6.dylib
  Referenced from: .venv/lib/python3.9/site-packages/PIL/.dylibs/libxcb.1.1.0.dylib
  Reason: no suitable image found.  Did find:
    .venv/lib/python3.9/site-packages/PIL/.dylibs/libXdmcp.6.dylib: cannot load 'libXdmcp.6.dylib' (load command 0x80000034 is unknown)
    .venv/lib/python3.9/site-packages/PIL/.dylibs/libXdmcp.6.dylib: cannot load 'libXdmcp.6.dylib' (load command 0x80000034 is unknown)

Have seen this on two different machines and it was reproducible on both after recreating a venv.

radarhere commented 1 year ago

Hi. What version of macOS are you using?

nixis-institute commented 1 year ago

Same issue with me i'm using 10.13.6 (macOS High Sierra)

jbeghtol commented 1 year ago

For myself, it was Mojave 10.14.6.

jbeghtol commented 1 year ago

Also if helpful, I thought the DLC path when looking at the dependencies of the failing dylib curious as its invalid

(.venv) justin@mac:~/.venv/lib/python3.8/site-packages/PIL/.dylibs$ otool -L libxcb.1.1.0.dylib
libxcb.1.1.0.dylib:
    /DLC/PIL/.dylibs/libxcb.1.1.0.dylib (compatibility version 3.0.0, current version 3.0.0)
    @loader_path/libXau.6.0.0.dylib (compatibility version 7.0.0, current version 7.0.0)
    @loader_path/libXdmcp.6.dylib (compatibility version 7.0.0, current version 7.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)
radarhere commented 1 year ago

Thanks. The problem was occurring for macOS < 11.

https://github.com/python-pillow/pillow-wheels/pull/358 has been merged to fix this for future Pillow wheels. If you would like an immediate solution, https://github.com/python-pillow/pillow-wheels/suites/10193756587/artifacts/499253201 has fixed wheels.

radarhere commented 1 year ago

I've uploaded new Pillow 9.4.0 wheels to PyPI. If you try installing from pip again, the problem should be fixed.

jbeghtol commented 1 year ago

Appreciate the quick response! Not sure how to tell when the wheel is updated, I tried to pip3 cache purge, installed 9.4.0 and got Pillow-9.4.0-1-cp38-cp38-macosx_10_10_x86_64.whl which has the same issue, but maybe not updated?

Collecting Pillow==9.4.0
  Downloading Pillow-9.4.0-1-cp38-cp38-macosx_10_10_x86_64.whl (3.3 MB)
...
Successfully installed Pillow-9.4.0
(.venv) justin@mac:~$ python3
>>> from PIL import Image
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/justin/.venv/lib/python3.8/site-packages/PIL/Image.py", line 103, in <module>
    from . import _imaging as core
ImportError: dlopen(/Users/justin/.venv/lib/python3.8/site-packages/PIL/_imaging.cpython-38-darwin.so, 2): Library not loaded: @loader_path/libXdmcp.6.dylib
radarhere commented 1 year ago

Pillow-9.4.0-1-cp38-cp38-macosx_10_10_x86_64.whl should be working. Could you uninstall Pillow, check that Pillow can't be imported, and then install again?

jgrean81 commented 1 year ago

I am having this issue today. New workspace, venv, install pillow, bam. Mac OS 10.13.6

Import error for .venv/lib/python3.9/site-packages/PIL/.dylibs/libXdmcp.6.dylib: cannot load 'libXdmcp.6.dylib' (load command 0x80000034 is unknown)

As above, uninstalled pillow, then pip3 cache purge, then verified I could not import, before reinstalling pillow. Same error.

radarhere commented 1 year ago

I've created a zip of the new wheels from https://pypi.org/project/Pillow/#files. If you install one of the wheels from it - pillow-macos.zip - using python3 -m pip install Pillow-9.4.0-1-cp38-cp38-macosx_10_10_x86_64.whl (or whichever wheel matches your Python version) then does that work? I am hoping this is just caching somewhere along the line.

radarhere commented 1 year ago

Unfortunately, GitHub Actions won't allow me to test 10.13 or 10.14.

10.15 works as far as I see - https://github.com/radarhere/Pillow/actions/runs/3870668581

yacineCo commented 1 year ago

Hi everyone, i am have also the same issue but with matplotlib (like you @jbeghtol i am Mojave 10.14.6)

I have tried to uninstall/reinstall package on a new venv it doesn't work at all.

radarhere commented 1 year ago

If you download the wheels from the zip in my earlier comment, and python3 -m pip install Pillow-9.4.0-1-cp38-cp38-macosx_10_10_x86_64.whl (or whichever wheel matches your Python version) then does that work?

yacineCo commented 1 year ago

i am currently downloading it, but excuse me for the noob question but can you tell me where i have to put the wheel downloaded file ?

here is the complete code error returned by vscode :

ImportError                               Traceback (most recent call last)
Cell In[1], line 1
----> 1 import matplotlib

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/matplotlib/__init__.py:113
    109 from packaging.version import parse as parse_version
    111 # cbook must import matplotlib only within function
    112 # definitions, so it is safe to import from it here.
--> 113 from . import _api, _version, cbook, _docstring, rcsetup
    114 from matplotlib.cbook import sanitize_sequence
    115 from matplotlib._api import MatplotlibDeprecationWarning

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/matplotlib/rcsetup.py:27
     25 from matplotlib import _api, cbook
     26 from matplotlib.cbook import ls_mapper
---> 27 from matplotlib.colors import Colormap, is_color_like
     28 from matplotlib._fontconfig_pattern import parse_fontconfig_pattern
     29 from matplotlib._enums import JoinStyle, CapStyle

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/matplotlib/colors.py:51
     49 from numbers import Number
     50 import re
---> 51 from PIL import Image
     52 from PIL.PngImagePlugin import PngInfo
     54 import matplotlib as mpl

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/Image.py:103
     94 MAX_IMAGE_PIXELS = int(1024 * 1024 * 1024 // 4 // 3)
     97 try:
     98     # If the _imaging C module is not present, Pillow will not load.
     99     # Note that other modules should not refer to _imaging directly;
    100     # import Image and use the Image.core variable instead.
    101     # Also note that Image.core is not a publicly documented interface,
    102     # and should be considered private and subject to change.
--> 103     from . import _imaging as core
    105     if __version__ != getattr(core, "PILLOW_VERSION", None):
    106         msg = (
    107             "The _imaging extension was built for another version of Pillow or PIL:\n"
    108             f"Core version: {getattr(core, 'PILLOW_VERSION', None)}\n"
    109             f"Pillow version: {__version__}"
    110         )

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/_imaging.cpython-310-darwin.so, 2): Library not loaded: @loader_path/libXdmcp.6.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/.dylibs/libxcb.1.1.0.dylib
  Reason: no suitable image found.  Did find:
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/.dylibs/libXdmcp.6.dylib: cannot load 'libXdmcp.6.dylib' (load command 0x80000034 is unknown)
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/.dylibs/libXdmcp.6.dylib: cannot load 'libXdmcp.6.dylib' (load command 0x80000034 is unknown)
radarhere commented 1 year ago

Ask away.

You don't need to put it anywhere. Once you have run the install command, you can get rid of it. So,

  1. Download the zip and extract it
  2. cd to that directory in your Terminal
  3. Uninstall your current Pillow with python3 -m pip uninstall Pillow
  4. Install from this new wheel with python3 -m pip install Pillow-9.4.0-1-cp310-cp310-macosx_10_10_x86_64.whl

and then see if it works? I hope it does, but it is conceivable that it won't.

yacineCo commented 1 year ago

Found existing installation: Pillow 9.4.0 Uninstalling Pillow-9.4.0: Would remove: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/ /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/Pillow-9.4.0.dist-info/ Proceed (Y/n)?

I am not sure but it seems that i have the same version of Pillow

radarhere commented 1 year ago

Yes, proceed.

yacineCo commented 1 year ago

i did, then :

In terminal : --> cd (path to where i downloaded your file) --> python3 -m pip install Pillow-9.4.0-1-cp310-cp310-macosx_10_10_x86_64.whl --> (installation completed OK)

then relaunched vscode --> trying to import matplotlib --> same error.... i am pretty desperate...

@radarhere do you have any other ideas ? thanks by the way for the help

hugovk commented 1 year ago

It sounds like you have a different Python interpreter in VS Code compared to your terminal.

Can you check them?

On the terminal, what do you get for:

python3 --version --version
which python3

I don't use VS Code, but can you check which Python you have running there?

yacineCo commented 1 year ago
$ python3 --version --version
Python 3.10.7 (v3.10.7:6cc6b13308, Sep  5 2022, 14:02:52) [Clang 13.0.0 (clang-1300.0.29.30)]
$ which python3
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3
yacineCo commented 1 year ago

I have certainly an issue with pillow because of this error message :

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/matplotlib/colors.py:51
     49 from numbers import Number
     50 import re
---> 51 from PIL import Image
     52 from PIL.PngImagePlugin import PngInfo
     54 import matplotlib as mpl
yacineCo commented 1 year ago
ImportError: 
dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/_imaging.cpython-310-darwin.so, 2): Library not loaded: @loader_path/libXdmcp.6.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/.dylibs/libxcb.1.1.0.dylib

**Reason: no suitable image found.**  

Did find:
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/.dylibs/libXdmcp.6.dylib: cannot load 'libXdmcp.6.dylib' (load command 0x80000034 is unknown)
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/.dylibs/libXdmcp.6.dylib: cannot load 'libXdmcp.6.dylib' (load command 0x80000034 is unknown)
radarhere commented 1 year ago

From Terminal, are you able to run python3 -c "from PIL import Image" without any errors?

yacineCo commented 1 year ago

@radarhere Nope, here is the message

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/Image.py", line 103, in <module>
    from . import _imaging as core
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/_imaging.cpython-310-darwin.so, 2): Library not loaded: @loader_path/libXdmcp.6.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/.dylibs/libxcb.1.1.0.dylib
  Reason: no suitable image found.  Did find:
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/.dylibs/libXdmcp.6.dylib: cannot load 'libXdmcp.6.dylib' (load command 0x80000034 is unknown)
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/.dylibs/libXdmcp.6.dylib: cannot load 'libXdmcp.6.dylib' (load command 0x80000034 is unknown)
radarhere commented 1 year ago

Hmm. Thanks for that info. If you require an immediate solution, you could try downgrading to Pillow 9.3.0 - python3 -m pip install --force-reinstall Pillow==9.3.0

yacineCo commented 1 year ago

i got a new error :

ImportError: The _imaging extension was built for another version of Pillow or PIL:
Core version: 9.3.0
Pillow version: 9.4.0

does PIL and Pillow are two different package ?

yacineCo commented 1 year ago

@radarhere when i try to install PIL (pip install PIL) here is the msg i got :

ERROR: Could not find a version that satisfies the requirement PIL (from versions: none) ERROR: No matching distribution found for PIL

radarhere commented 1 year ago

Pillow is a fork of PIL. PIL hasn't had a new release in a long time, so I wouldn't try installing it.

"The _imaging extension was built for another version" should just mean that you didn't properly uninstall one version of Pillow before installing another. Try uninstalling Pillow again, make sure that there is nothing called PIL or Pillow in "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/", and then try re-installing Pillow.

yacineCo commented 1 year ago

@radarhere Do you know where can i get the file : "libXdmcp.6.dylib" i think that i understand my error. It all comes from PIL.

i have a cascading issues from PIL and it affects all the following fils Image.py > colors.py > rcsetup.py > init.py

yacineCo commented 1 year ago

i am having this error :

WARNING: Requirement 'Pillow-9.4.0-1-cp310-cp310-macosx_10_10_x86_64.whl' looks like a filename, but the file does not exist Processing ./Pillow-9.4.0-1-cp310-cp310-macosx_10_10_x86_64.whl ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/matplotlib/Pillow-9.4.0-1-cp310-cp310-macosx_10_10_x86_64.whl'

yacineCo commented 1 year ago

@radarhere Hey andrew i am sorry but your proccedure is working (this one), i re-did it (i guess, i didn't downloaded the good version)

1 Download the zip and extract it 2 cd to that directory in your Terminal 3 Uninstall your current Pillow with python3 -m pip uninstall Pillow 4 Install from this new wheel with python3 -m pip install Pillow-9.4.0-1-cp310-cp310-macosx_10_10_x86_64.whl

Thanks you very much for the support

jbeghtol commented 1 year ago

@radarhere I'm still getting the same error when I install directly from the whl file from your zip above

(.venv) justin@mac:~/pil$ pip3 uninstall Pillow
Found existing installation: Pillow 9.4.0
Uninstalling Pillow-9.4.0:
  Would remove:
    /Users/justin/.venv/lib/python3.8/site-packages/PIL/*
    /Users/justin/.venv/lib/python3.8/site-packages/Pillow-9.4.0.dist-info/*
Proceed (Y/n)? y
  Successfully uninstalled Pillow-9.4.0
(.venv) justin@mac:~/pil$ pip3 install Pillow-9.4.0-1-cp38-cp38-macosx_10_10_x86_64.whl
Processing ./Pillow-9.4.0-1-cp38-cp38-macosx_10_10_x86_64.whl
Installing collected packages: Pillow
Successfully installed Pillow-9.4.0
(.venv) justin@mac:~/pil$ python3
Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/justin/.venv/lib/python3.8/site-packages/PIL/Image.py", line 103, in <module>
    from . import _imaging as core
ImportError: dlopen(/Users/justin/.venv/lib/python3.8/site-packages/PIL/_imaging.cpython-38-darwin.so, 2): Library not loaded: @loader_path/libXdmcp.6.dylib
  Referenced from: /Users/justin/.venv/lib/python3.8/site-packages/PIL/.dylibs/libxcb.1.1.0.dylib
hugovk commented 1 year ago

Is your pip3 using the same Python interpreter as python3?

Instead of pip3, any difference with python3 -m pip?

re: https://snarky.ca/why-you-should-use-python-m-pip/

jbeghtol commented 1 year ago

@hugovk I mean I assume so, though I didn't realize it wasn't just an alias. thx for the tip there. but I did try with python3 -m pip and got the same experience

hugovk commented 1 year ago

OK, thanks. What do you get for ls -l /Users/justin/.venv/lib/python3.8/site-packages/PIL/.dylibs/?

Here's a diff of the contents of the old and new wheels:

image

jbeghtol commented 1 year ago

One really curious thing... I have an entirely separate mac running the same version (10.14.6) with python 3.9.4 and this doesn't happen there.

ls -l when installing from whl file (seems identical to from pip install)

-rwxr-xr-x  1 justin  staff    53856 Jan  9 08:21 libXau.6.dylib
-rw-r--r--  1 justin  staff    54224 Jan  9 08:21 libXdmcp.6.dylib
-rwxr-xr-x  1 justin  staff   185360 Jan  9 08:21 libbrotlicommon.1.0.9.dylib
-rwxr-xr-x  1 justin  staff    88208 Jan  9 08:21 libbrotlidec.1.0.9.dylib
-rwxr-xr-x  1 justin  staff  1097776 Jan  9 08:21 libfreetype.6.dylib
-rwxr-xr-x  1 justin  staff  3840752 Jan  9 08:21 libharfbuzz.0.dylib
-rwxr-xr-x  1 justin  staff   508832 Jan  9 08:21 liblcms2.2.dylib
-rwxr-xr-x  1 justin  staff   308624 Jan  9 08:21 liblzma.5.dylib
-rwxr-xr-x  1 justin  staff   636160 Jan  9 08:21 libopenjp2.2.5.0.dylib
-rwxr-xr-x  1 justin  staff   313120 Jan  9 08:21 libpng16.16.dylib
-rwxr-xr-x  1 justin  staff  1219280 Jan  9 08:21 libtiff.6.dylib
-rwxr-xr-x  1 justin  staff   691520 Jan  9 08:21 libwebp.7.dylib
-rwxr-xr-x  1 justin  staff    53696 Jan  9 08:21 libwebpdemux.2.dylib
-rwxr-xr-x  1 justin  staff    89952 Jan  9 08:21 libwebpmux.3.dylib
-rwxr-xr-x  1 justin  staff   262896 Jan  9 08:21 libxcb.1.1.0.dylib
-rwxr-xr-x  1 justin  staff   175872 Jan  9 08:21 libz.1.2.13.dylib
radarhere commented 1 year ago

Ok, @yacineCo was able to install a downloaded wheel successfully, @jbeghtol experienced success on a different machine, and there was the success story from a user that prompted the uploading of the new wheels.

So this is sounding like the new wheels are correct, we just need to help individuals in this issue to install them.

jbeghtol commented 1 year ago

It seems like libXdmcp.6.dylib doesn't load on some platforms, and I don't understand this 'load command 0x80000034 is unknown' error which comes with it. I did export DYLD_PRINT_LIBRARIES=1 to watch libraries loading on both, and on my failing system it gets through loading

venv/lib/python3.8/site-packages/PIL/.dylibs/libXau.6.dylib

Then unloads everything and errors out. There are definitely libraries outside the wheel deployed libs that get loaded as a result of importing Image from PIL, so it seems maybe some conflict in those that get loaded ahead?

This is the load list from the failing system:

dyld: loaded: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/math.cpython-38-darwin.so
dyld: loaded: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/_struct.cpython-38-darwin.so
dyld: loaded: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/zlib.cpython-38-darwin.so
dyld: loaded: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/_bz2.cpython-38-darwin.so
dyld: loaded: /usr/lib/libbz2.1.0.dylib
dyld: loaded: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/_lzma.cpython-38-darwin.so
dyld: loaded: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/grp.cpython-38-darwin.so
dyld: loaded: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/_bisect.cpython-38-darwin.so
dyld: loaded: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/_sha512.cpython-38-darwin.so
dyld: loaded: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/_random.cpython-38-darwin.so
dyld: loaded: /Users/justin/.venv/lib/python3.8/site-packages/PIL/_imaging.cpython-38-darwin.so
dyld: loaded: /Users/justin/.venv/lib/python3.8/site-packages/PIL/.dylibs/libopenjp2.2.5.0.dylib
dyld: loaded: /Users/justin/.venv/lib/python3.8/site-packages/PIL/.dylibs/libz.1.2.13.dylib
dyld: loaded: /Users/justin/.venv/lib/python3.8/site-packages/PIL/.dylibs/libtiff.6.dylib
dyld: loaded: /Users/justin/.venv/lib/python3.8/site-packages/PIL/.dylibs/libxcb.1.1.0.dylib
dyld: loaded: /Users/justin/.venv/lib/python3.8/site-packages/PIL/.dylibs/liblzma.5.dylib
dyld: loaded: /Users/justin/.venv/lib/python3.8/site-packages/PIL/.dylibs/libXau.6.dylib
dyld: unloaded: /Users/justin/.venv/lib/python3.8/site-packages/PIL/_imaging.cpython-38-darwin.so
radarhere commented 1 year ago

In case it is helpful to anyone, here are wheels without libxcb - Pillow-9.4.0-without-libxcb.zip. This is not an ideal solution for us, because it is disabling functionality, but if you are struggling with the previous options and would like an immediate solution, they should work.

radarhere commented 1 year ago

If there is still a problem, and you are feeling motivated, here is a series of wheels, starting from Pillow 9.3.0, and working its way towards Pillow 9.4.0. I wouId presume that number zero will pass, and number five will fail, and it would be interesting to know when it stops passing and starts failing.

0-930.zip 1-openblas.zip 2-xz.zip 3-libXau.zip 4-pypy.zip 5-940.zip

Diyoupiyou commented 1 year ago

I have the same issue. I managed to re install pillow without libxcb (no luck with the other wheels on Mac OS 10.14.6) but when importing matplotlib I still get the error :

ImportError: The _imaging extension was built for another version of Pillow or PIL: Core version: 9.3.0 Pillow version: 9.4.0

Diyoupiyou commented 1 year ago

ha never mind restarting my notebook after the last comment seems to allow Matplotlib import without alerts this time...

JRYPZFQeqh commented 1 year ago

just noting that i've had the exact same issues here w/ libxcb on OSX v10.14.6, and this was my process to fix the error and proceed w/ the code i was trying to run::

  1. uninstall Pillow via python3 -m pip uninstall Pillow
  2. download the .zip without libxcb from the post above; unzip
  3. reinstall Pillow via python3 -m pip install Pillow-9.4.0-cp310-cp310-macosx_10_10_x86_64.whl
  4. run my code as normal without error

thanks @radarhere for your help!

nulano commented 1 year ago

If there is still a problem, and you are feeling motivated, here is a series of wheels, starting from Pillow 9.3.0, and working its way towards Pillow 9.4.0. I wouId presume that number zero will pass, and number five will fail, and it would be interesting to know when it stops passing and starts failing.

0-930.zip 1-openblas.zip 2-xz.zip 3-libXau.zip 4-pypy.zip 5-940.zip

The error message in the top comment is Library not loaded: @loader_path/libXdmcp.6.dylib.

I do not have a macOS system, but using 7-Zip on Windows I can see that both the 930 and 940 wheels have the same libXdmcp.6.dylib (with matching SHA1 hash), presumably the one that is incompatible based on the error message. From prior experience, I think this incompatibility is caused by an upgrade in the GitHub Actions macOS image, so even rerunning the old releases will produce incompatible wheels.

I therefore added brew remove libxdmcp before building the wheels. Checking with 7-Zip, I can see that libXdmcp.6.dylib is no longer included in the wheels with this change. Based on its readme file, I do not think this library is useful with Pillow:

The libXdmcp package contains a library implementing the X Display Manager Control Protocol. This is useful for allowing clients to interact with the X Display Manager.

To make sure, someone would have to set up a connection to an X11 server on macOS (either a native X server or forwarded over SSH) and run ImageGrab.grab(xdisplay=...) to check. Assuming that works with these wheels, the library libXdmcp is not used by Pillow and can be safely removed (saving ~10KB per wheel).

Would anyone be able to test the wheels in this zip file no-libxdmcp-wheels.zip to confirm they work on macOS<10.15?

yacineCo commented 1 year ago

sorry @nulano, this far beyond my level of comprehension.... i don't know how to set up and X11 server in macOS. All i can do is to uninstall my current version of pillow and install the new wheel you provided (with your patch "brew remove libxdmcp ") but if it messed up my install.... my murdered intent will grow (i spent 1 day pour to make Matplotlib working.....). Do you want me to proceed?

nulano commented 1 year ago

If you don't know how to connect to an X11 server that is fine, I may actually be able to test that myself in a few weeks.

Just testing that the wheels install correctly and you can import PIL.Image would be enough to test my theory, but if you aren't comfortable testing it, maybe someone else would be. In any case, to test the wheels you just need to run the following commands:

python3 -m pip uninstall Pillow
python3 -m pip install <path/to/the_downloaded_wheel.whl>
python3 -m PIL

Hopefully that successfully installs the wheels in my previous comment and prints out information about the install. If it doesn't work, you can do the same using the wheel that did work for you previously to undo the change.

yacineCo commented 1 year ago

@nulano here are results of the test you asked :

python3 -m pip uninstall Pillow
python3 -m pip install <path/to/the_downloaded_wheel.whl>
python3 -m PIL
--------------------------------------------------------------------
Pillow 9.4.0
Python 3.10.7 (v3.10.7:6cc6b13308, Sep  5 2022, 14:02:52) [Clang 13.0.0 (clang-1300.0.29.30)]
--------------------------------------------------------------------
Python modules loaded from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL
Binary modules loaded from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 9.4.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.12.1
--- LITTLECMS2 support ok, loaded 2.14
--- WEBP support ok, loaded 1.2.4
--- WEBP Transparency support ok
--- WEBPMUX support ok
--- WEBP Animation support ok
--- JPEG support ok, compiled for libjpeg-turbo 2.1.4
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.0
--- ZLIB (PNG/ZIP) support ok, loaded 1.2.13
--- LIBTIFF support ok, loaded 4.5.0
*** RAQM (Bidirectional Text) support not installed
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------
BLP
Extensions: .blp
Features: open, save, encode
--------------------------------------------------------------------
BMP image/bmp
Extensions: .bmp
Features: open, save
--------------------------------------------------------------------
BUFR
Extensions: .bufr
Features: open, save
--------------------------------------------------------------------
CUR
Extensions: .cur
Features: open
--------------------------------------------------------------------
DCX
Extensions: .dcx
Features: open
--------------------------------------------------------------------
DDS
Extensions: .dds
Features: open, save
--------------------------------------------------------------------
DIB image/bmp
Extensions: .dib
Features: open, save
--------------------------------------------------------------------
EPS application/postscript
Extensions: .eps, .ps
Features: open, save
--------------------------------------------------------------------
FITS
Extensions: .fit, .fits
Features: open, save
--------------------------------------------------------------------
FLI
Extensions: .flc, .fli
Features: open
--------------------------------------------------------------------
FTEX
Extensions: .ftc, .ftu
Features: open
--------------------------------------------------------------------
GBR
Extensions: .gbr
Features: open
--------------------------------------------------------------------
GIF image/gif
Extensions: .gif
Features: open, save, save_all
--------------------------------------------------------------------
GRIB
Extensions: .grib
Features: open, save
--------------------------------------------------------------------
HDF5
Extensions: .h5, .hdf
Features: open, save
--------------------------------------------------------------------
ICNS image/icns
Extensions: .icns
Features: open, save
--------------------------------------------------------------------
ICO image/x-icon
Extensions: .ico
Features: open, save
--------------------------------------------------------------------
IM
Extensions: .im
Features: open, save
--------------------------------------------------------------------
IMT
Features: open
--------------------------------------------------------------------
IPTC
Extensions: .iim
Features: open
--------------------------------------------------------------------
JPEG image/jpeg
Extensions: .jfif, .jpe, .jpeg, .jpg
Features: open, save
--------------------------------------------------------------------
JPEG2000 image/jp2
Extensions: .j2c, .j2k, .jp2, .jpc, .jpf, .jpx
Features: open, save
--------------------------------------------------------------------
MCIDAS
Features: open
--------------------------------------------------------------------
MPEG video/mpeg
Extensions: .mpeg, .mpg
Features: open
--------------------------------------------------------------------
MSP
Extensions: .msp
Features: open, save, decode
--------------------------------------------------------------------
PCD
Extensions: .pcd
Features: open
--------------------------------------------------------------------
PCX image/x-pcx
Extensions: .pcx
Features: open, save
--------------------------------------------------------------------
PIXAR
Extensions: .pxr
Features: open
--------------------------------------------------------------------
PNG image/png
Extensions: .apng, .png
Features: open, save, save_all
--------------------------------------------------------------------
PPM image/x-portable-anymap
Extensions: .pbm, .pgm, .pnm, .ppm
Features: open, save
--------------------------------------------------------------------
PSD image/vnd.adobe.photoshop
Extensions: .psd
Features: open
--------------------------------------------------------------------
SGI image/sgi
Extensions: .bw, .rgb, .rgba, .sgi
Features: open, save
--------------------------------------------------------------------
SPIDER
Features: open, save
--------------------------------------------------------------------
SUN
Extensions: .ras
Features: open
--------------------------------------------------------------------
TGA image/x-tga
Extensions: .icb, .tga, .vda, .vst
Features: open, save
--------------------------------------------------------------------
TIFF image/tiff
Extensions: .tif, .tiff
Features: open, save, save_all
--------------------------------------------------------------------
WEBP image/webp
Extensions: .webp
Features: open, save, save_all
--------------------------------------------------------------------
WMF
Extensions: .emf, .wmf
Features: open, save
--------------------------------------------------------------------
XBM image/xbm
Extensions: .xbm
Features: open, save
--------------------------------------------------------------------
XPM image/xpm
Extensions: .xpm
Features: open
--------------------------------------------------------------------
XVTHUMB
Features: open
--------------------------------------------------------------------

And Matplotlib works also perfectly : image

is there anything else you want me to do ?

PS : Sry i don't know why my copy/paste is so big....

radarhere commented 1 year ago

If @nulano's idea is correct, then I wonder if we don't need https://github.com/python-pillow/pillow-wheels/pull/358 after all?

While I don't have a machine with macOS < 11, I do have an x86-64 mac. I reverted https://github.com/python-pillow/pillow-wheels/pull/358, added brew remove libxdmcp, created wheels and installed one. I was able to run ImageGrab.grab(xdisplay="") without an error.

Pillow-without-libxdmcp-or-358.zip

wiredfool commented 1 year ago

I've got a Mojave mac here for some legacy 32 bit applications, but it doesn't have any dev stuff on it at all. (as well as a PPC mini. ... somewhere.)

jbeghtol commented 1 year ago

@radarhere I tried your Pillow without libxdmcp-or-358 on my failing platform and did not encounter any errors. I could import Image and could execute the ImageGrab.grab also without issues.