我正在使用Ubuntu 12.04而且我在PIL-hell。我已经尝试了我可以在网上找到安装PIL的方法的所有建议,但我没有运气。我知道一个事实,我有各种依赖。我已经尝试了所有的符号链接方法。我修改了setup.py文件以确保它找到正确的目录。我也尝试过从源码构建并通过pip进行安装。什么都行不通。这是我安装时得到的:
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.3 (default, Nov 4 2012, 15:42:19)
[GCC 4.4.3]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------
以下是selftest.py显示的内容:
--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from ./PIL
Binary modules loaded from ./PIL
--------------------------------------------------------------------
--- PIL CORE support ok
*** TKINTER support not installed
*** JPEG support not installed
*** ZLIB (PNG/ZIP) support not installed
*** FREETYPE2 support not installed
*** LITTLECMS support not installed
--------------------------------------------------------------------
我不知道还有什么可以尝试的。我只想尝试一些愚蠢的PNG文件...
答案 0 :(得分:9)
最简单的方法应该如下:
sudo apt-get install python-imaging
如果你需要在virtualenv中安装,或者想要绝对最新版本使用pip。首先安装一些需要的东西,然后运行pip install:
sudo apt-get install libjpeg-dev libjpeg62 libjpeg62-dev zlib1g-dev libfreetype6 libfreetype6-dev
pip install PIL
回复以下评论。如果您全新安装ubuntu 12.04并运行apt-get install python-imaging
,您将在系统上正确安装PIL。在我运行selftest.py时,在我的ubuntu 12.04框中,我得到以下输出:
--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from /usr/lib/python2.7/dist-packages/PIL
Binary modules loaded from /usr/lib/python2.7/dist-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok
*** TKINTER support not installed
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok
--- LITTLECMS support ok
--------------------------------------------------------------------
您正在寻找的PNG支持显示为正常。我怀疑你的python安装可能处于某种腐败状态。也许您提到的符号链接或其他安装此软件包的尝试已损坏您的安装。我可以提出三条建议来纠正这种情况
<强>解决方案强>
apt-get purge python-imaging
,然后重新安装python-imaging软件包。答案 1 :(得分:4)
如果你在Ubuntu 64位上运行,除了Marwan之外可能还需要另外一步:
PIL设置在/usr/lib
中查找库,但Ubuntu 64将它们放在/usr/lib/x86_64-linux-gnu
上。一个有效的解决方案是创建链接:
sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
答案 2 :(得分:1)
我遇到了PIL和Pillow一起安装的问题。
如果我使用apt-get install python-imaging
安装PIL,然后运行selftest.py
我就会收到(这很好):
--- PIL CORE support ok
*** TKINTER support not installed
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok
--- LITTLECMS support ok
如果我然后通过sudo pip install Pillow
安装Pillow然后重新运行selftest.py
,我会得到:
--- PIL CORE support ok
*** TKINTER support not available
(Tcl/Tk 8.5 libraries needed)
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
*** TIFF G3/G4 (experimental) support not available
*** FREETYPE2 support not available
*** LITTLECMS support not available
*** WEBP support not available
为了解决多个“支持不可用”并重新回到初始状态,我刚刚卸载了Pillow。