Problem installing PIL using virtualenv or buildout

When I install PIL using easy_install or buildout, it is set in such a way that I have to do the “import image” and not “from the import PIL image”.

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

Here are examples of how I am 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 the easy_install package is PIL in Egg, but PIP is not. Same with buildbot, it uses eggs.

How could I properly install PIL using easy_install or buildout?

+68
python pip easy-install python-imaging-library buildout
Mar 21 '10 at 0:19
source share
4 answers

The PIL version packaged in pypi (by the author) is not compatible with setuptools and therefore is not easy_installable. People created an easy_installable version elsewhere. Currently, you need to specify the URL of the search links and use pip to get a good package:

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

Using pip install with --no-index , you do not --no-index risk of finding the PyPI (unfixed) original PIL. If you used easy_install , you should use a direct link to the source archive of the fixed version; easy_install stubbornly still uses the PyPI link at the URL of the search links:

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

To enable PIL in buildout, specify either an egg with the same version number, or use the version section:

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

Change March 2011. Now, fixes to solve packaging problems have been merged into the PIL Development Tree , so this workaround may soon become obsolete.

Edit February 2013: just use the Pillow and do with it. :-) I explicitly expect the original package to be fixed, it has not paid off.

+95
Mar 21 '10 at 8:22
source share

Use the Pillow: a “friendly” PIL plug :-) It offers:

  • Full compatibility with setuptools
  • Faster Release Cycle
  • No changes to the image code other than PIL (i.e., it is designed to track all changes to the PIL image code and not make any changes without reporting them upstream.)
  • Windows binaries

If PIL does what Pillow does, then the plug will die. Until this happens, we have a Pillow.

DISCLAIMER . I am the author of fork, and Pillow was created mainly to make my work easier (although it's great to see other people using it too).

EDIT : Pillow 2.0.0 was released on March 15, 2013. It offers Python 3 support and many bug fixes / improvements. Although we are still trying to track the changes with the PIL up (unfortunately or, fortunately, depending on how you look at it), the pillow began to move away from PIL.

+78
Oct 14 '11 at 16:19
source share

For Ubuntu, I found that I need to install the C header package for my python version (2.7)

sudo apt-get install python2.7-dev

Then pip install pil worked.

+7
Feb 14 '13 at 18:45
source share

On Windows, I installed PIL in virtualenv as follows:

Install PIL in your global python packages by executing the .exe file: http://www.pythonware.com/products/pil/

Then, as "do it yourself-er," copy the PIL.pth file and the PIL directory in C: \ Python25 \ Lib \ site-packages to the virtual sitesite directory. Yes, python is still "polluting your hands" ...

+5
Nov 30 '12 at 10:03
source share



All Articles