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

Pillow on OSX arm64 #5276

Closed
francishunger opened this issue Feb 22, 2021 · 4 comments
Closed

Pillow on OSX arm64 #5276

francishunger opened this issue Feb 22, 2021 · 4 comments
Labels
Installation Usually a problem with … macOS

Comments

@francishunger
Copy link

francishunger commented Feb 22, 2021

How do I tell pip where Pillow needs to look for Pillow-Modules (like libjpeg, libtiff?)
I'm on OSX Big Sur, arm64 architecture and need Python 3.8 in order to run Keras.

  • OS: Big Sur 11.2
  • Python: 3.8
  • Pillow: 8.1.0

As per instruction on the homebrew website I have installed python 3.8 and its packages into /opt/homebrew/lib/python3.8/

python3 -m pip install Pillow --no-cache-dir 
Collecting Pillow
  Downloading Pillow-8.1.0.tar.gz (44.9 MB)
     |████████████████████████████████| 44.9 MB 1.3 MB/s 
Building wheels for collected packages: Pillow
  Building wheel for Pillow (setup.py) ... done
  Created wheel for Pillow: filename=Pillow-8.1.0-cp38-cp38-macosx_11_0_arm64.whl size=528914 sha256=fa6d3dac05ed7f101de315304c41aa43b86b622a41ee745ab28f9376bc65b9ab
  Stored in directory: /private/var/folders/nw/40xtxx5s5rld0d0hddbndnf00000gn/T/pip-ephem-wheel-cache-3ob_jkx9/wheels/4e/db/04/9dcbaf9865568850d9bbdeb9b6b697e70f804d18e7e8aac050
Successfully built Pillow
Installing collected packages: Pillow
Successfully installed Pillow-8.1.0

When I called Python with

import PIL
from PIL import Image

I've got the following error message

from PIL import Image
  File "/Users/name/Library/Python/3.8/lib/python/site-packages/PIL/Image.py", line 94, in <module>
    from . import _imaging as core
ImportError: dlopen(/Users/name/Library/Python/3.8/lib/python/site-packages/PIL/_imaging.cpython-38-darwin.so, 2): Symbol not found: _jpeg_resync_to_restart
  Referenced from: /Users/name/Library/Python/3.8/lib/python/site-packages/PIL/_imaging.cpython-38-darwin.so
  Expected in: flat namespace
 in /Users/francis/Library/Python/3.8/lib/python/site-packages/PIL/_imaging.cpython-38-darwin.so

now
brew install libjpeg
successfully installed libjpeg, but the error remained.

So I manually installed libjpeg to /usr/local/lib and it solved the problem.

curl -L -O http://ijg.org/files/jpegsrc.v9d.tar.gz
tar -xvf jpegsrc.v9d.tar.gz
cd jpeg-9d
./configure CFLAGS="-arch arm64" CXXFLAGS="-arch arm64" LDFLAGS="-arch arm64" CC="clang"
make
sudo make install

Only for the next error to occur, which was a missing libtiff. Yet libtiff is allready brewed and installed at /opt/homebrew/Cellar/libtiff/4.2.0. Again it didn't an Pillow now throws this error on runtime:

…
ImportError: dlopen(/Users/name/Library/Python/3.8/lib/python/site-packages/PIL/_imaging.cpython-38-darwin.so, 2): Symbol not found: _TIFFClientOpen
  Referenced from: /Users/name/Library/Python/3.8/lib/python/site-packages
…

How do I solve this beyond installing libtiff manually (because it goes on with further modules, doesn't it)?

@radarhere
Copy link
Member

Hi. Part of the problem here is that Pillow hasn't yet uploaded arm64 wheels to PyPI. If you are interested in a quick and easy solution, I would recommend downloading the wheel from #5093 (comment), expanding, and then python3 -m pip install Pillow-8.0.1-cp38-cp38-macosx_11_0_arm64.whl

I would also like to point out though that "Python 3.8.7 is not yet fully supported on macOS 11 Big Sur." (and Python 3.8.8 says nothing new on that front) - so the official Python guideline would be to use Python 3.9 instead, as "3.9.1 is the first version of Python to support macOS 11 Big Sur."

@radarhere
Copy link
Member

What does brew --prefix output?

@radarhere radarhere added macOS Installation Usually a problem with … labels Feb 23, 2021
@francishunger
Copy link
Author

brew --prefix

$ /opt/homebrew

@francishunger
Copy link
Author

I uninstalled pillow and reinstalled it from the above mentioned wheel. This time it worked. I think earlier, when I tried that I had my homebrew still installed under /usr/lib and the pillow of the wheel v.8.0.1 failed to install because I had pillow v.8.1.0 installed elsewhere.

Thanks for your comments. now I wonder, if I should uninstall the manually installed libjpeg. Let's see. Thanks so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Installation Usually a problem with … macOS
Projects
None yet
Development

No branches or pull requests

2 participants