PIL /JPEG 库:“解码器 jpeg 不可用”
我尝试使用 PIL 在我的 django 应用程序中使用 PIL 执行一些 JPEG 工作,但我收到此 IOError.. 不知道该怎么做。
""decoder jpeg not available""
我的服务器是否缺少 JPEG 解码器?如果是这样,我该如何修复它?
I tried to use PIL to do some JPEG work in my django app with PIL but I'm getting this IOError.. not sure what to do.
""decoder jpeg not available""
Am I missing the JPEG decoder from my server? If so, how do I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我从作者“edward”那里找到了这个答案
在 Ubuntu 上,PIL 找不到 jpeg 库文件,即使安装了它们也是如此。解决此问题的最简单方法是在安装 jpeg 开发包后创建符号链接。因此,我需要一个额外的步骤:
对于 x64 操作系统
对于 x32 操作系统
我确认这在 Ubuntu Linux 12.04 上对我有用。
如果您是 Mac 用户 - 您需要安装 Xcode 和命令行工具。 了解如何执行此操作
I have found this answer from author "edward"
On Ubuntu precise, PIL doesn't find the jpeg library files, even once they are installed. The easiest way to fix this is to make a symlink after you have installed the jpeg dev package. So, I needed an extra step:
for x64 OS
for x32 OS
I confirm that this is working for me on Ubuntu Linux 12.04.
If you are a Mac user - you need to install Xcode and Command Line Tools. Read how to do this
您需要先安装 jpeg 库并重新安装 PIL。比如我用的是CentOS,要安装libjpeg,我运行
它取决于你使用的是什么类型的linux。这里你必须删除旧的PIL
然后安装PIL
You need to install jpeg library first and reinstall your PIL. For example, I'm using CentOS, to install libjpeg, I run
It depends on what kind of linux you are using. And here you have to remove the old PIL
Then install the PIL
可以在 使用 libjpeg 在 virtualenv 上安装 pil 找到更强有力的答案
。最后在 Ubutu 上工作的是:
Python 成像库 (PIL) 似乎对 jpeg 库的版本和位置非常挑剔。由于 PIL 是用 C 语言编写并编译的,因此除了运行时版本之外,您还需要该库的开发版本。
A stronger answer can be found at install pil on virtualenv with libjpeg
For me what finally worked on Ubutu was:
The Python Imaging Library (PIL) seems really picky about version and location of the jpeg libraries. And because PIL is written in C and compiled, you need the development versions of the library in addition to the runtime versions.
我没有 sudo 权限,因为我位于共享的 bluehost 服务器上。所以我无法运行任何 sudo apt-get jpeg 命令。我最终运行了
,显然枕头能够找到对 jpeg 的支持。
I don't have sudo privileges, because I am on a shared bluehost server. So I can't run any of those sudo apt-get jpeg commands. I ended up running
and apparently pillow was able to find support for jpegs.
你的Imaging安装文件夹中有一个selftest.py,尝试一下:
你会看到类似这样的内容:
如果JPEG支持不可用,Centos:
There is a selftest.py in your Imaging installation folder, try:
you will see something like that:
if JPEG support not available, Centos:
对于 Mac 用户,您可以从这里下载该库: http://ethan.tira-thompson.com /Mac_OS_X_Ports.html。然后,卸载并安装PIL
For mac's users, You can download the library from here: http://ethan.tira-thompson.com/Mac_OS_X_Ports.html. Then, uninstall and install PIL
您可以从源代码构建 PIL: http://effbot.org/zone/ pil-解码器-jpeg-not-available.htm
You can build PIL from source: http://effbot.org/zone/pil-decoder-jpeg-not-available.htm
在 Debian 发行版上使用 libjpeg62-turbo-dev 而不是 libjpeg8-dev
On Debian distributions use libjpeg62-turbo-dev instead of libjpeg8-dev