Python PIL 找不到我的“libjpeg”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1486157/
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
Python PIL cannot locate my "libjpeg"
提问by TIMEX
I cannot use PIL because it cannot find my libjpeg!
我不能使用 PIL,因为它找不到我的 libjpeg!
First, I installed PIL default. And when I ran the selftest.py
, it gave me:
首先,我默认安装了 PIL。当我运行时selftest.py
,它给了我:
IOError: decoder jpeg not available 1
items had failures: 1 of 57 in
selftest.testimage
***Test Failed*** 1 failures.
*** 1 tests of 57 failed.
Then, I followed instructions online to change PIL's setup.py
to
然后,我按照在线说明将 PIL 更改setup.py
为
JPEG_ROOT = "/usr/lib"
Because when I locate libjpeg
, this is what I get:
因为当我locate libjpeg
,这就是我得到的:
locate libjpeg
/usr/lib/libjpeg.so.62
/usr/lib/libjpeg.so.62.0.0
/usr/lib64/libjpeg.so.62
/usr/lib64/libjpeg.so.62.0.0
/usr/share/doc/libjpeg-6b
/usr/share/doc/libjpeg-6b/README
/usr/share/doc/libjpeg-6b/usage.doc
/var/cache/yum/base/packages/libjpeg-6b-37.i386.rpm
/var/cache/yum/base/packages/libjpeg-6b-37.x86_64.rpm
So, I ran setup.py install
again...and did selftest.py
.
And I still get the same error!
所以,我又跑setup.py install
了……然后就跑了selftest.py
。我仍然遇到同样的错误!
回答by NerdyNick
There at least 3 header sets that you will want to install. 1 more if you want to deal with Tiff's
您至少需要安装 3 个标头集。如果您想与 Tiff 打交道,还有 1 个
freetype, libjpeg, zlib all of which will be in the following packages on CentOS:
freetype、libjpeg、zlib 所有这些都将在 CentOS 上的以下软件包中:
== 32 Bit: zlib-devel.i386 libjpeg-devel.i386 freetype-devel.i386
== 32 位:zlib-devel.i386 libjpeg-devel.i386 freetype-devel.i386
== 64 Bit: zlib-devel.x86_64 libjpeg-devel.x86_64 freetype-devel.x86_64
== 64 位:zlib-devel.x86_64 libjpeg-devel.x86_64 freetype-devel.x86_64
As you did before you will want to edit the following variables in the setup.py file:
正如您之前所做的那样,您需要在 setup.py 文件中编辑以下变量:
FREETYPE_ROOT JPEG_ROOT ZLIB_ROOT
FREETYPE_ROOT JPEG_ROOT ZLIB_ROOT
Setting there values to /usr/lib or /usr/lib64 based on your platform. Once done you will most likely want to run
根据您的平台将这些值设置为 /usr/lib 或 /usr/lib64。完成后,您很可能想要运行
python setup.py build --force
python setup.py install
That will force rebuild all your lib for PIL and reinstall them raw.
这将强制为 PIL 重建所有库并重新安装它们。
回答by Lennart Regebro
You need the libjpeg headers as well, not only the library itself. Those packages are typically called something ending in headers or dev, depending on what distribution you have.
您还需要 libjpeg 头文件,而不仅仅是库本身。这些包通常被称为以 headers 或 dev 结尾的东西,具体取决于您拥有的发行版。
回答by rhinoinrepose
I had the same issue. In my case, I need to set:
我遇到过同样的问题。就我而言,我需要设置:
JPEG_ROOT="/usr/lib64/"
instead of:
代替:
JPEG_ROOT="/usr/lib/"
Good luck.
祝你好运。
回答by Mark van Lent
You could also try to use Pillowinstead of PIL.
您也可以尝试使用Pillow而不是 PIL。
Pillow is a PIL fork to "foster active development of PIL". In versions 1.7.0 and 1.7.1 they made some changes to support multi-arch (see the changelog).
Pillow 是一个 PIL 分支,旨在“促进 PIL 的积极发展”。在 1.7.0 和 1.7.1 版本中,他们进行了一些更改以支持多架构(请参阅更改日志)。
回答by Marcio Mangar
Today I was facing the same problem, and I've found the solution. Basically it involves remove the PIL, install lipjpeg through Fink and re-install the PIL.
今天我遇到了同样的问题,我找到了解决方案。基本上它涉及删除 PIL,通过 Fink 安装 lipjpeg 并重新安装 PIL。
I wrote an articletelling step by step how to do that. If interesting check this out.
我写了一篇文章,一步一步告诉你如何做到这一点。如果有趣,请查看此内容。