Im using sorl.thumbnail for django locally on my mac and have been having trouble with PIL, but today i finally managed to get it installed - was some trouble with libjpeg.
I can now upload and use images - but I cant resize them using sorl.thumbnail.
When i try i get the following error:
Wrong JPEG library version: library is 80, caller expects 62
Does anyone know a good solution for this.
I dont know wether whatever sorl uses requires an earlier version of libjpeg or wether there is some ghost install of something still left behind from all of my tries with various methods.
I have :
- PIL 1.1.7
- libjpeg 8.
anyone know an approach?
If you have macports installed, you should do a:
It's easier than the easy_install method since macports install the right dependencies.
I had a slightly different problem than the OP, but I wanted to share my solution here to help someone in the future.
OS: OSX El Capitan I installed libjpeg-turbo from the precompiled binaries on their website. However, I did not know that I already had a different version of libjpeg installed on my mac. I was building my c file like this
gcc myfile.c -o myfile.out -L /opt/libjpeg-turbo/lib -ljpeg
. This got the library from the correct location, but the the linker was getting the included header filejpeglib.h
from the pre-installed location. I changed my build command to this:gcc myfile.c -o myfile.out -I/opt/libjpeg-turbo/include/ -L /opt/libjpeg-turbo/lib -ljpeg
and it worked. No more library is 80, caller expects 62!For the benefit of the people from the future who are encountering this error and don't know why, I'd like to post my findings. I hope to give a general understanding of what's gone wrong since the exact commands to fix it may be different on your machine than on my OSX Lion install.
First, since it's easy to get lost in the potential solutions, it's important to understand that the error message is correct when it says
Wrong JPEG library version: library is 80, caller expects 62
or some other combination of62
,70
, and80
. These numbers correspond to the different incompatible versions of libjpeg. There are two moving pieces here, the dynamically loaded jpeg library, and the PIL (or Pillow) install. What the error message is saying is that your PIL install was compiled with headers from libjpeg version 6.2, but when it goes to load up the actual shared library, it's being linked to version 8.0.The fix is to download, build, and install the libjpeg version you want (any will do, though the later versions build easier on OSX Lion):
This should drop 2 files of note in '/usr/local/'. Namely
/usr/local/lib/libjpeg.8.dylib
and/usr/local/include/jpeglib.h
. Now we just have to get PIL (or Pillow) to use these two files at install time, and we're home free. I know there's a better way to do this, but the hack (as recommended by the PIL docs) is to edit thesetup.py
file of the PIL distribution before you install it. You may get away with just settingJPEG_ROOT = libinclude('/usr/local')
near the top ofsetup.py
, though further directory manipulation may be necessary elsewhere in the file.As you fiddle with the paths, you have to make sure PIL does a full rebuild before you test out whether it linked up to the right library or not. I used a command like
rm -rf build && python setup.py install
to make sure the library was always freshly linked to the current path I was testing.I'm sorry this is a rambling answer, but it was very disheartening to have tried every other copy & paste solution out there and have none of them work. Hopefully this answer keeps at least a few folks from wasting numerous hours in search of a simplistic solution.
Good Luck!