views:

815

answers:

2

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?

A: 

I don't see a problem. You shouldn't need to import from PIL, so there is no issue.

Ignacio Vazquez-Abrams
3rd party modules expect to import Image from the PIL package. You can't go round and change all of those for a project.
Martijn Pieters
@Martijn: If third-party code imports from the `PIL` package then they are wrong, since the *very first* line of code from the PIL tutorial is `import Image`. http://www.pythonware.com/library/pil/handbook/introduction.htm
Ignacio Vazquez-Abrams
There is a long discussion about PIL's packaging problems elsewhere on the web, StackOverflow is not the place to expound on that. You'll notice that the Debian packaging places PIL in the PIL namespace too. In short, by not using a namespace PIL would conflict with other python modules named 'Image'.
Martijn Pieters
+7  A: 

The PIL version packaged on pypi (by the author) is fundamentally mis-packaged. People have created easy_installable versions elsewhere. Currently, you need to specify a find-links URL and pin the version to get a good package:

easy_install -f http://dist.plone.org/thirdparty/ -U PIL==1.1.7

The version pin is needed because any newer versions on pypi may not yet have been repackaged, and the mispackaged version would be found and downloaded instead.

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
Martijn Pieters
Is the author being notified about this, so that it gets fixed on pypi, too?
blueyed
I've understood that the author isn't interested in fixing this on pypi.
Martijn Pieters