Can't get PIL to correctly install on Ubuntu 12.04

后端 未结 3 1649
时光说笑
时光说笑 2021-01-05 12:18

I\'m using Ubuntu 12.04 and I\'m in PIL-hell. I\'ve tried every suggestion I can find online for ways to install PIL, but I have no luck. I know for a fact I have every de

3条回答
  •  感动是毒
    2021-01-05 13:07

    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. First install some stuff pil needs, then run the 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. on my ubuntu 12.04 box when I run selftest.py I get the following output:

    --------------------------------------------------------------------
    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. I suspect that your python installation is probably in some sort of corrupt state. 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. This should definitely work.
    2. create a python virtualenv and then install PIL there using pip. This might work depending on how corrupt the base python system is. The idea here is that virtualenv by default will create a new python environment that only has the standard library in it.
    3. repair your python installation. You could try apt-get purge python-imaging and then re-install the python-imaging package.

提交回复
热议问题