Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

class Image has no attribute 'open' [duplicate]

Possible Duplicate:
img = Image.open(fp) AttributeError: class Image has no attribute ‘open’

So I am trying to view pictures in python with tkinter. I installed PIL and I am trying to open a picture but I keep getting an attribute error saying "class Image has no attribute 'open'

from __future__ import division
from PIL import Image
from Tkinter import *
import random

img = Image.open("majestic creature.jpeg").convert("RGB")

This isn't all the code I have but this is the part that the program seems to have trouble with.

like image 415
Clockwork Avatar asked Nov 11 '12 22:11

Clockwork


1 Answers

From the looks of what you have said, namely This is not all of the code.
You or some other import has declared some variable / class called Image and this has overwritten the Image class that was imported by PIL.

To specifically use the PIL Image class use:

img = PIL.Image.open("majestic creature.jpeg").convert("RGB")
like image 117
Serdalis Avatar answered Nov 08 '22 05:11

Serdalis