PIL /JPEG 库:“解码器 jpeg 不可用”

发布于 2024-10-11 03:33:12 字数 176 浏览 3 评论 0原文

我尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

羁拥 2024-10-18 03:33:12

我从作者“edward”那里找到了这个答案

在 Ubuntu 上,PIL 找不到 jpeg 库文件,即使安装了它们也是如此。解决此问题的最简单方法是在安装 jpeg 开发包后创建符号链接。因此,我需要一个额外的步骤:

对于 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

对于 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

我确认这在 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

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

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.


If you are a Mac user - you need to install Xcode and Command Line Tools. Read how to do this

衣神在巴黎 2024-10-18 03:33:12

您需要先安装 jpeg 库并重新安装 PIL。比如我用的是CentOS,要安装libjpeg,我运行

sudo yum install -y libjpeg-devel

它取决于你使用的是什么类型的linux。这里你必须删除旧的PIL

rm -rf /usr/lib/python2.6/site-packages/PIL-1.1.7-py2.6-linux-x86_64.egg/

然后安装PIL

sudo easy_install PIL

You need to install jpeg library first and reinstall your PIL. For example, I'm using CentOS, to install libjpeg, I run

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

rm -rf /usr/lib/python2.6/site-packages/PIL-1.1.7-py2.6-linux-x86_64.egg/

Then install the PIL

sudo easy_install PIL
又爬满兰若 2024-10-18 03:33:12

可以在 使用 libjpeg 在 vi​​rtualenv 上安装 pil 找到更强有力的答案

。最后在 Ubutu 上工作的是:

pip uninstall PIL
sudo apt-get install libjpeg8-dev
pip install PIL

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:

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 development versions of the library in addition to the runtime versions.

妞丶爷亲个 2024-10-18 03:33:12

我没有 sudo 权限,因为我位于共享的 bluehost 服务器上。所以我无法运行任何 sudo apt-get jpeg 命令。我最终运行了

pip uninstall pil
pip install pillow

,显然枕头能够找到对 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

pip uninstall pil
pip install pillow

and apparently pillow was able to find support for jpegs.

等风也等你 2024-10-18 03:33:12

你的Imaging安装文件夹中有一个selftest.py,尝试一下:

python selftest.py

你会看到类似这样的内容:

--------------------------------------------------------------------
*** 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
--------------------------------------------------------------------

如果JPEG支持不可用,Centos:

yum install libjpeg-devel
yum install freetype-devel 
yum install libpng-devel

There is a selftest.py in your Imaging installation folder, try:

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:

yum install libjpeg-devel
yum install freetype-devel 
yum install libpng-devel
蓝海似她心 2024-10-18 03:33:12

对于 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

春夜浅 2024-10-18 03:33:12

在 Debian 发行版上使用 libjpeg62-turbo-dev 而不是 libjpeg8-dev

On Debian distributions use libjpeg62-turbo-dev instead of libjpeg8-dev

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文