Search code examples
pythonimagemacospython-imaging-library

Python PIL compatibility with Image


To use Image, I did the following:

pip install pil

from PIL import Image

But many programs just want Image:

import Image

How can I use import Image as well?


Solution

  • Basically you can use any of the methods mentioned here.

    On my linux installation, PIL already uses one of those - there's a directory called PILcompat which has files like Image.py, and a file called PILcompat.pth which is used to tell python to add this directory to its module search path. This way when

     import Image 
    

    is executed, python finds PILcompat/Image.py which executes its contents -

     from PIL.Image import *
    

    I'm guessing either the .pth file or the directory are missing on your machine.