Question

I have Ubuntu 12.04 (Precise Pangolin) installed and some package installed, PIL. Now I want to use Pillow, but that cannot be installed at the same time as PIL.

I looked at virtualenv, but there are other packages I don't want to have to install.

Is there another way to set this up without the clash?

Was it helpful?

Solution

You should install Pillow from the Git clone with (choose /opt/pillow as you want):

python setup.py install --prefix /opt/pillow

And then it include in your code,

import sys
sys.path.insert(0, "/opt/pillow")

before doing the import of Pillow with

from PIL import Image

This will search the /opt/pillow directory first and anything without that insert will never see Pillow.

OTHER TIPS

I set up a fork of Pillow that properly masquerades its package name arbitrarily, when built with the environment variable PILLOW_NAME set (e.g. PILLOW_NAME=PIL). So you can install Pillow under the PIL package name like this:

$ PILLOW_NAME=PIL pip install -U https://github.com/fish2000/Pillow/archive/master.zip

... If you wish, you can check the custom package-name installation like so:

$ pip freeze | grep -i pil
[...]
PIL==2.3.0
$ python -c 'from PIL import Image' && echo "PIL installed OK"
PIL installed OK

If you have this Pillow fork installed under the name “PIL” you’ll be able to install packages that call for PIL as a requirement. Bear in mind: this will not help you if those packages rely on old PIL-specific behavior (e.g. import Image and friends) – but it will get you past the name issue when installing packages that specifically require PIL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top