Reputation: 11728
i am trying to do something with the PIL Image library in django, but i experience some problems.
I do like this:
import Image
And then I do like this
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 leeds me to think that its not imported correctly, anybody know?
type object 'Image' has no attribute 'open'
Upvotes: 0
Views: 2767
Reputation: 26566
The error above happens because your file is called Image.py and you're trying to import yourself. As Manual pointed out, you should import Image from the PIL module, but you'd also need to rename your file so it's not called Image.py.
Upvotes: 1
Reputation: 8456
Your example works fine in my machine. I don't know why you're getting that error. PIL documentation say you have to import the library in this way:
from PIL import Image
You should try that way. As I said, for me works in both ways.
Upvotes: 0