Django OS X Wrong JPEG library version: library is

2019-03-16 20:49发布

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 :

  1. PIL 1.1.7
  2. libjpeg 8.

anyone know an approach?

3条回答
兄弟一词,经得起流年.
2楼-- · 2019-03-16 20:59

If you have macports installed, you should do a:

$ sudo port selfupdate
$ sudo port install py27-pil

It's easier than the easy_install method since macports install the right dependencies.

查看更多
聊天终结者
3楼-- · 2019-03-16 20:59

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 file jpeglib.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!

查看更多
唯我独甜
4楼-- · 2019-03-16 21:14

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 of 62, 70, and 80. 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):

 wget http://www.ijg.org/files/jpegsrc.v8d.tar.gz
 tar xzf jpegsrc*
 cd jpeg-*
 ./configure
 make
 sudo make install

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 the setup.py file of the PIL distribution before you install it. You may get away with just setting JPEG_ROOT = libinclude('/usr/local') near the top of setup.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!

查看更多
登录 后发表回答