Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pillow import error from _imaging.so / libjpeg.8.dylib on OSX

I've used Pillow in the past on OSX without problems, however I now get the following error.

  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 61, in <module>
    from PIL import _imaging as core
ImportError: dlopen(/Library/Python/2.7/site-packages/PIL/_imaging.so, 2):     Library not loaded: /usr/local/lib/libjpeg.8.dylib
  Referenced from: /Library/Python/2.7/site-packages/PIL/_imaging.so
  Reason: image not found

I've seen this question which appears to be a similar problem but I don't think I installed Pillow with brew.

I've also tried the solution from this question but the command

pip install PIL --allow-external PIL --allow-unverified PIL

dosent seem to work and I get an error (no such option: --allow-unverified)

Lastly, I've tried to recreate the symbolic link to libjpeg.8.dylib but that also did not make any difference.

Would anyone know how to fix this error? Do I need to do something to relink _image.so aswell as libjpeg?

like image 437
DavidJB Avatar asked Nov 10 '22 19:11

DavidJB


1 Answers

Python PIL was deprecated eons ago and you should not attempt to use it anymore.

What you want is python[23] -m pip install Pillow

PS. Using pip command will be deprecated soon because of confusions regarding python interpreters, instead of calling pip ... everyone should use only python -m pip ... which assures that is calling the right interpreter.

like image 161
sorin Avatar answered Nov 14 '22 21:11

sorin