Django OS X错误的JPEG库版本:库为80,调用者期望62 sorl.thumbnail [英] Django OS X Wrong JPEG library version: library is 80, caller expects 62 sorl.thumbnail

查看:119
本文介绍了Django OS X错误的JPEG库版本:库为80,调用者期望62 sorl.thumbnail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac上本地使用Django的sorl.thumbnail进行了PIL的安装,但是今天我终于设法安装了它-libjpeg出现了一些麻烦.

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.

我现在可以上传和使用图像了-但是我无法使用sorl.thumbnail调整它们的大小.

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.

我不知道无论使用什么sorl都需要libjpeg的早期版本,或者我在尝试各种方法后仍然遗留了一些鬼安装的东西.

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.

我有:

  1. PIL 1.1.7
  2. libjpeg 8.

有人知道一种方法吗?

推荐答案

为了将来遇到这个错误并且不知道为什么的人们的利益,我想发表我的发现.我希望大致了解发生了什么问题,因为修复该问题的确切命令可能在您的计算机上与在我的OSX Lion安装中不同.

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.

首先,由于很容易在潜在的解决方案中迷失方向,因此重要的是要理解该错误消息在显示Wrong JPEG library version: library is 80, caller expects 62627080的某些其他组合时是正确的.这些数字对应于libjpeg的不同不兼容版本.这里有两个动人的部分,一个是动态加载的jpeg库,另一个是PIL(或Pillow)安装.错误消息的意思是您的PIL安装是使用libjpeg 6.2版的标头编译的,但是当它要加载实际的共享库时,它将链接到8.0版.

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.

解决方法是下载,构建并安装所需的libjpeg版本(尽管可以这样做)更高的版本在OSX Lion上更容易构建):

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

这应该将2个注释文件放到'/usr/local/'中.即/usr/local/lib/libjpeg.8.dylib/usr/local/include/jpeglib.h.现在,我们只需要获取PIL(或Pillow)即可在安装时使用这两个文件,我们就可以免费使用了.我知道有一种更好的方法可以做到这一点,但是黑客(如PIL文档所建议)是在安装PIL发行版的setup.py文件之前对其进行编辑.您可能只是在setup.py顶部附近设置JPEG_ROOT = libinclude('/usr/local')就可以逃脱,尽管可能需要在文件的其他位置进行进一步的目录操作.

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.

在弄弄路径时,必须确保PIL进行了完全重建,然后才能测试它是否链接到正确的库.我使用了rm -rf build && python setup.py install这样的命令来确保该库始终始终与我正在测试的当前路径链接.

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.

祝你好运!

这篇关于Django OS X错误的JPEG库版本:库为80,调用者期望62 sorl.thumbnail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆