Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(Python PIL)AttributeError:
#1
AttributeError: type object 'Image' has no attribute 'open'
this error message come when i run my code
HELP ME GUYS.i am new programmer to python.i can't understand what i do
code given below
from PIL import *
import sqlite3
from tkinter import *

connection = sqlite3.connect("school.db")

tao = Tk()
tao.title("Mayurapada Central Collage")
tao.configure(bg = '#6699ff')
canvas = Canvas(tao,width = 600,height = 400,bg = '#6699ff')

def imgs():
    img = Image.open("C:\\Users\\TAO\\Desktop\\New\\02.png")
    img.show()
    str01 = "Image"
    font = ImageFont.truetype("arial.ttf",75)
    w,h = font.getsize(str01)
    print(str01)
               

button01 = Button(tao,text = "Preview",bd = 7,padx = 5,pady = 5,command = imgs).place(x = 50,y = 300)

canvas.pack()
tao.mainloop()
Reply
#2
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python34\lib\tkinter\__init__.py", line 1482, in __call__
    return self.func(*args)
  File "C:\Users\TAO\Desktop\New\b.py", line 14, in imgs
    img = Image.open("C:\\Users\\TAO\\Desktop\\New\\02.png")
AttributeError: type object 'Image' has no attribute 'open'
Reply
#3
cross-posted on SO
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python: Regex is not good for re.search (AttributeError: 'NoneType' object has no att Melcu54 9 1,470 Jun-28-2023, 11:13 AM
Last Post: Melcu54
  Python: AttributeError: 'PageObject' object has no attribute 'extract_images' Melcu54 2 3,867 Jun-18-2023, 07:47 PM
Last Post: Melcu54
  Getting Python error: AttributeError: 'tuple' object has no attribute 'Text' dageci 2 14,216 Jul-26-2018, 08:34 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020