AttributeError: module 'tkinter' has no attribute 'TK'. Did you mean: 'Tk'?

AttributeError: module ‘tkinter’ has no attribute ‘TK’. Did you mean: ‘Tk’?

In python AttributeError: module ‘tkinter’ has no attribute ‘TK’. Did you mean: ‘Tk’? we face this error message when we import tkinter and convert in variable but we need to use tkinter.Tk() [ small k ] but we use tkinter.TK( CAPITAL K ) then the python interpreter shows this error message, If you want to fix this error you need just use tkinter.Tk() [ small k ]  instead of tkinter.TK( CAPITAL K ), so this is one of the best ways to fix this python error, For more clarification, see the below example.

Wrong Code

import tkinter

window = tkinter.TK()


window.title("Amol Blog")
# Set the window size
window.geometry("400x400")


window.mainloop()

Error Massage

Traceback (most recent call last):
  File "/home/kali/python/webproject/error/main.py", line 3, in <module>
    window = tkinter.TK()
AttributeError: module 'tkinter' has no attribute 'TK'. Did you mean: 'Tk'?

Wrong code line

window = tkinter.TK() 
#tkinter.TK( CAPITAL K )

Correct code line

window = tkinter.Tk()
#tkinter.Tk( small k )
  • Improper action: tkinter.TK( CAPITAL K ).
  • Correct action: tkinter.Tk( small k ).

Entire Correct Code line

import tkinter

window = tkinter.Tk()


window.title("Amol Blog")
# Set the window size
window.geometry("400x400")


window.mainloop()

What is AttributeError: module ‘tkinter’ has no attribute ‘TK’. Did you mean: ‘Tk’?

In python, we face this error message when we import tkinter and convert in a variable but we need to use tkinter.Tk() [ small k ] but we use tkinter.TK( CAPITAL K ) then the python interpreter shows this error message.

How to fix AttributeError: module ‘tkinter’ has no attribute ‘TK’. Did you mean: ‘Tk’?

If you want to fix this error you need just use tkinter.Tk() [ small k ]  instead of tkinter.TK( CAPITAL K ), so this is one of the best ways to fix this python error, For more clarification, see the above example.

Another article for you: The fancy error in python.

For more information Visit YouTube Channel.

Scroll to Top
Basics of Python Interview Questions Valentine’s Day Python Special Code Evil Golden Turtle Python Game Pong Game In Python Top 7 Gaming Project In python