Python PIL /JPEG 库:“解码器 jpeg 不可用”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4632261/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PIL /JPEG Library: "decoder jpeg not available"
提问by Brian D
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.
我试图使用 PIL 在我的 django 应用程序中使用 PIL 做一些 JPEG 工作,但我收到了这个 IOError .. 不知道该怎么做。
""decoder jpeg not available""
Am I missing the JPEG decoder from my server? If so, how do I fix it?
我是否缺少服务器中的 JPEG 解码器?如果是这样,我该如何解决?
采纳答案by Fang-Pen Lin
You need to install jpeg library first and reinstall your PIL. For example, I'm using CentOS, to install libjpeg, I run
您需要先安装 jpeg 库并重新安装 PIL。例如,我使用 CentOS,要安装 libjpeg,我运行
sudo yum install -y libjpeg-devel
It depends on what kind of linux you are using. And here you have to remove the old PIL
这取决于您使用的 linux 类型。在这里你必须删除旧的 PIL
rm -rf /usr/lib/python2.6/site-packages/PIL-1.1.7-py2.6-linux-x86_64.egg/
Then install the PIL
然后安装PIL
sudo easy_install PIL
回答by TryPyPy
You can build PIL from source: http://effbot.org/zone/pil-decoder-jpeg-not-available.htm
您可以从源代码构建 PIL:http: //effbot.org/zone/pil-decoder-jpeg-not-available.htm
回答by Bryce
A stronger answer can be found at install pil on virtualenv with libjpeg
可以在使用 libjpeg 在 virtualenv上安装 pil 中找到更强有力的答案
For me what finally worked on Ubutu was:
对我来说,最终在 Ubutu 上起作用的是:
pip uninstall PIL
sudo apt-get install libjpeg8-dev
pip install PIL
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 developmentversions of the library in addition to the runtime versions.
Python Imaging Library (PIL) 似乎对 jpeg 库的版本和位置非常挑剔。由于 PIL 是用 C 编写并编译的,因此除了运行时版本之外,您还需要库的开发版本。
回答by Anton Danilchenko
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:
在 Ubuntu 上,即使安装了 jpeg 库文件,PIL 也找不到它们。解决此问题的最简单方法是在安装 jpeg dev 包后创建符号链接。所以,我需要一个额外的步骤:
for x64 OS
x64 操作系统
pip uninstall PIL
sudo apt-get install libjpeg8-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
pip install PIL
for x32 OS
x32 操作系统
pip uninstall PIL
sudo apt-get install libjpeg8-dev
sudo ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib
pip install PIL
I confirm that this is working for me on Ubuntu Linux 12.04.
我确认这在 Ubuntu Linux 12.04 上对我有用。
If you are a Macuser - you need to install Xcode and Command Line Tools. Read how to do this
如果您是Mac用户 - 您需要安装 Xcode 和命令行工具。阅读如何执行此操作
回答by Chase Roberts
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
我没有 sudo 权限,因为我在共享的 bluehost 服务器上。所以我无法运行任何 sudo apt-get jpeg 命令。我跑了
pip uninstall pil
pip install pillow
and apparently pillow was able to find support for jpegs.
显然枕头能够找到对 jpeg 的支持。
回答by cmaluenda
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
对于 mac 用户,您可以从这里下载库:http: //ethan.tira-thompson.com/Mac_OS_X_Ports.html。然后,卸载并安装 PIL
回答by hahakubile
There is a selftest.py in your Imaging installation folder, try:
您的 Imaging 安装文件夹中有一个 selftest.py,请尝试:
python selftest.py
you will see something like that:
你会看到类似的东西:
--------------------------------------------------------------------
*** PIL CORE support not installed
*** TKINTER support not installed
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
*** FREETYPE2 support not installed
*** LITTLECMS support not installed
--------------------------------------------------------------------
if JPEG support not available, Centos:
如果 JPEG 支持不可用,Centos:
yum install libjpeg-devel
yum install freetype-devel
yum install libpng-devel
回答by Steve
On Debian distributions use libjpeg62-turbo-dev instead of libjpeg8-dev
在 Debian 发行版上使用 libjpeg62-turbo-dev 而不是 libjpeg8-dev

