Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The problem with installing PIL using virtualenv or buildout

When I install PIL using easy_install or buildout it installs in such way, that I must do 'import Image', not 'from PIL import Image'.

However, if I do "apt-get install python-imaging" or use "pip -E test_pil install PIL", all work fine.

Here are examples of how I trying to install PIL using virtualenv:

# virtualenv --no-site-packages test_pil # test_pil/bin/easy_install PIL # test_pil/bin/python Python 2.5.1 (r251:54863, Feb  6 2009, 19:02:12)  [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import PIL Traceback (most recent call last):   File "<stdin>", line 1, in <module> ImportError: No module named PIL 

I see, that easy_install pack PIL into the Egg, and PIP does not. Same thing with buildbot, it uses eggs.

How could I install PIL properly, using easy_install or buildout?

like image 329
Alexander Artemenko Avatar asked Mar 21 '10 00:03

Alexander Artemenko


People also ask

Do I need to install packages in virtual environment?

Installing virtualenv venv is included in the Python standard library and requires no additional installation. If you are using venv, you may skip this section. virtualenv is used to manage Python packages for different projects.

What is PIL in Pycharm?

PIL is the Python Imaging Library by Fredrik Lundh and Contributors.


1 Answers

The PIL version packaged on pypi (by the author) is incompatible with setuptools and thus not easy_installable. People have created easy_installable versions elsewhere. Currently, you need to specify a find-links URL and use pip get a good package:

pip install --no-index -f http://dist.plone.org/thirdparty/ -U PIL 

By using pip install with the --no-index you avoid running the risk of finding the PyPI (non-fixed) original of PIL. If you were to use easy_install, you must use a direct link to the source tarball of a corrected version; easy_install stubbornly still uses the PyPI link over the find-links URL:

easy_install http://dist.plone.org/thirdparty/PIL-1.1.7.tar.gz 

To include PIL in a buildout, either specify the egg with the same version pin or use a versions section:

[buildout] parts = find-links =     http://dist.plone.org/thirdparty/ eggs =     PIL versions = versions  [versions] PIL = 1.1.7 

Edit March 2011: Fixes to address the packaging issues have been merged into PIL's development tree now, so this workaround may soon be obsolete.

Edit February 2013: Just use Pillow and be done with it. :-) Clearly waiting for the original package to be fixed has not paid off.

like image 133
Martijn Pieters Avatar answered Sep 28 '22 01:09

Martijn Pieters