[Fixed]-PIL – libjpeg.so.8: cannot open shared object file: No such file or directory


See an explanation here: Why can't Python find shared objects that are in directories in sys.path?

A quick fix is to add the directory that contains libjpeg.so.8 to your /etc/ld.so.conf file, and then run ldconfig


Also if you are doing local Python installations you can also control dynamic linking on the session level using LD_LIBRARY_PATH environment variable::

 export LD_LIBRARY_PATH=/srv/plone/python/python-2.6/lib
 import _imaging

This way you cannot break your OS itself, even accidentally. (It happens: http://opensourcehacker.com/2011/08/31/zend-server-installation-potentially-kills-your-ssh/)


Compiling the library from source works too: http://www.ijg.org/files/

Make sure to use jpegsrc.v8.tar.gz if you’re on a Unix like system though. jpegsr8.zip appears to be the MS version, and throws all the standard formatting issues while building.



maybe just install libjpeg

conda install -c conda-forge libjpeg-turbo

Leave a comment