Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PIL Library not loaded: /opt/local/lib/libjpeg.9.dylib

I have a perfectly running website designed in django, but accidentally i uninstalled homebrew and hence all the packages postgres, Pillow etc., had been lost and hence installed all of them again, but when i run the django runserver i got the below error

Unhandled exception in thread started by <function wrapper at 0x1071c11b8>
Traceback (most recent call last):
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/utils/autoreload.py", line 93, in wrapper
    fn(*args, **kwargs)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 101, in inner_run
    self.validate(display_num_errors=True)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/core/management/base.py", line 310, in validate
    num_errors = get_validation_errors(s, app)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/core/management/validation.py", line 34, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/db/models/loading.py", line 196, in get_app_errors
    self._populate()
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/db/models/loading.py", line 78, in _populate
    self.load_app(app_name)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/db/models/loading.py", line 99, in load_app
    models = import_module('%s.models' % app_name)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/Users/shivakrishna/shiva/app/post-web-1.6/modes/directory/models.py", line 24, in <module>
    from PIL import Image, ImageDraw, ImageFont
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/PIL/Image.py", line 67, in <module>
    from PIL import _imaging as core
ImportError: dlopen(/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/PIL/_imaging.so, 2): Library not loaded: /opt/local/lib/libjpeg.9.dylib
  Referenced from: /Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/PIL/_imaging.so
  Reason: image not found

I tried everything that was available on stackoverflow posts related to it like

brew uninstall libjpeg
brew install libjpeg

But none of them worked, and my brew list

boost       gdal        gmp     liblwgeom   libxml2     mysql       postgis     sfcgal
cgal        geoip       jpeg        libpng      little-cms2 openssl     postgresql  sqlite
freetype    geos        json-c      libspatialite   lzlib       pcre        proj        webp
freexl      giflib      libgeotiff  libtiff     mpfr        pillow      readline

So why it can't load /opt/local/lib/libjpeg.9.dylib library ? and how to fix it ?

like image 570
Shiva Krishna Bavandla Avatar asked Sep 14 '25 06:09

Shiva Krishna Bavandla


1 Answers

For this particular kind of issue the following worked for me

pip install --upgrade pillow
like image 87
Shiva Krishna Bavandla Avatar answered Sep 16 '25 21:09

Shiva Krishna Bavandla