简体   繁体   English

无法让PIL在Ubuntu 12.04上正确安装

[英]Can't get PIL to correctly install on Ubuntu 12.04

I'm using Ubuntu 12.04 and I'm in PIL-hell. 我正在使用Ubuntu 12.04,并且在PIL-hell中。 I've tried every suggestion I can find online for ways to install PIL, but I have no luck. 我已经尝试了所有可以在网上找到的有关安装PIL的建议,但是我没有运气。 I know for a fact I have every dependency. 我知道事实上我有很多依赖。 I've tried all of the symlink methods. 我已经尝试了所有的symlink方法。 I've modified the setup.py file to ensure it finds the correct directories. 我已经修改了setup.py文件,以确保找到正确的目录。 I've also tried building from source and installing through pip. 我也尝试过从源代码构建并通过pip安装。 Nothing works. 什么都没有。 Here's what I get when I install: 这是我安装时得到的:

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

Here's what selftest.py shows: 这是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
--------------------------------------------------------------------

I have no idea what else to try. 我不知道还有什么尝试。 I'm just trying to play with some stupid PNG files... 我只是想玩一些愚蠢的PNG文件...

the simplest way should be the following: 最简单的方法如下:

sudo apt-get install python-imaging

if you need to install in a virtualenv, or want the absolute latest version use pip. 如果您需要安装在virtualenv中,或者想要绝对最新的版本,请使用pip。 First install some stuff pil needs, then run the pip install: 首先安装一些需要pil的东西,然后运行pip install:

sudo apt-get install libjpeg-dev libjpeg62 libjpeg62-dev zlib1g-dev libfreetype6 libfreetype6-dev
pip install PIL

To respond to the comment below. 回应以下评论。 If you take a fresh installation of ubuntu 12.04 and run apt-get install python-imaging you will have PIL installed correctly on your system. 如果您全新安装ubuntu 12.04并运行apt-get install python-imaging ,则会在系统上正确安装PIL。 on my ubuntu 12.04 box when I run selftest.py I get the following output: 在我运行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 support which you are looking for shows as ok. 您正在寻找的PNG支持显示正常。 I suspect that your python installation is probably in some sort of corrupt state. 我怀疑您的python安装可能处于某种损坏状态。 Maybe the symlinking you mentioned or other attempts at installing this package has corrupted your installation. 您提到的符号链接或其他尝试安装此软件包的尝试可能已破坏了安装。 There are three recommendations I can give for correcting this situation 对于纠正这种情况,我可以提出三点建议

Solutions 解决方案

  1. re-install ubuntu on the machine. 在计算机上重新安装ubuntu。 This should definitely work. 这绝对应该工作。
  2. create a python virtualenv and then install PIL there using pip. 创建一个python virtualenv ,然后使用pip在其中安装PIL。 This might work depending on how corrupt the base python system is. 这可能有效,取决于基本python系统的损坏程度。 The idea here is that virtualenv by default will create a new python environment that only has the standard library in it. 这里的想法是默认情况下virtualenv将创建一个新的python环境,其中仅包含标准库。
  3. repair your python installation. 修复您的python安装。 You could try apt-get purge python-imaging and then re-install the python-imaging package. 您可以尝试apt-get purge python-imaging ,然后重新安装python-imaging软件包。

If you are running on Ubuntu 64 bit another step may be needed in addition to Marwan ones: 如果您在Ubuntu 64位上运行,则可能需要除Marwan之外的另一步骤:

PIL setup looks for libraries in /usr/lib but Ubuntu 64 places them on /usr/lib/x86_64-linux-gnu . PIL安装程序在/usr/lib寻找库,但是Ubuntu 64将它们放在/usr/lib/x86_64-linux-gnu A working solution is to create links: 一个可行的解决方案是创建链接:

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

I've experienced problems with PIL and Pillow installed together . 我在安装PIL和Pillow时遇到了问题

If I install PIL using apt-get install python-imaging and then run selftest.py I get (which is fine): 如果我使用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

If I then install Pillow through sudo pip install Pillow and then re-run selftest.py I get: 如果然后通过sudo pip install 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

In order to solve the multiple "supports not available" and get back to the initial status I just uninstalled Pillow. 为了解决多个“不可用的支持”并回到初始状态,我刚刚卸载了Pillow。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM