use of import of PIL incorrectly documented, or is it just me?

Fredrik Lundh fredrik at pythonware.com
Tue May 1 07:22:57 EDT 2001


Max Møller Rasmussen wrote:
> When I try to use the PIL, I have to use:
>
> from pil import Image
>
> To get the module to load.
>
> But the documentation say:
>
> import Image
>
> Have I misunderstood how it works

your copy of PIL isn't properly installed; from the README:

   Copy the "_imaging.so" module, the "_imagingtk.so" module, and the
   contents of the "PIL" subdirectory to a suitable place along the
   Python path.

   If you're using Python 1.5 or later, the preferred way is to create
   a "PIL" subdirectory under "site-packages", copy the "PIL.pth" file
   to "site-packages", and the rest of the files to the new subdirectory.

   Example:

        $ cp PIL.pth /usr/local/lib/Python1.5/site-packages
        $ mkdir /usr/local/lib/Python1.5/site-packages/PIL
        $ cp *.so PIL/* /usr/local/lib/Python1.5/site-packages/PIL

   You can also place the "PIL" subdirectory anywhere along the Python
   path, and use PIL as a package.

the documentation assumes that you use the PIL.pth approach.

(and even if you use the package approach, it should be "from PIL
import", not "from pil import")

Cheers /F





More information about the Python-list mailing list