Question :
Module ‘tkinter’ has no attribute ‘Tk’
Tkinter doesnt contain any tk attribute.
import tkinter
window = tkinter.Tk()
win.mainloop()
While running this code it gives me an error saying
module 'tkinter' has no attribute 'Tk'
Answer #1:
Did you named your python file tkinter.py or Tkinter.py ? Try to rename it. It may be the cause.
Answer #2:
Python 3.x
import tkinter
window = tkinter.Tk()
window.mainloop()
Answer #3:
import tkinter
raiz= tkinter.Tk()
raiz.mainloop()
remember that the file name cannot be tkinter.py
Answer #4:
try ‘Tk’ instead of ‘tk’
it worked for me, if you think you are importing wrong,try:
import tkinter
tkinter._test()
Answer #5:
Try copying the file to the Python path in C drive (in my case)
And the folder should not contain any other file named Tkinter.py or similar for Code click here