Problem importing PIL image library

I am trying to do something with the PIL image library in django but I am having some problems.

I like the following:

import Image

And then I like it

images = map(Image.open, glob.glob(os.path.join(dirpath, '*.thumb.jpg')))

But when I try to run this I get an error and it seems to me that it is not imported correctly, does anyone know?

type object 'Image' has no attribute 'open'

0


source to share


2 answers


The error above is happening because your file is called Image.py and you are trying to import yourself. As stated in the manual, you have to import Image from the PIL module, but you will also need to rename the file so that it is not named Image.py.



+1


source


Your example works fine on my machine. I don't know why you are getting this error. The PIL documentation says that you need to import the library like this:

from PIL import Image

      



You should try this way. As I said, it works both ways for me.

0


source







All Articles