How to fix NameError, Tk() not defined

102 Views Asked by At

I'm trying to use tkinter in Pycharm but it does not work.

from tkinter import *

fenster = Tk()

fenster.title("Fenster")

fenster.mainloop()`

It also does not work on the terminal, because the error "NameError: name 'Tk' is not defined" occurs.

The tkinter._test() works fine the terminal.

1

There are 1 best solutions below

1
On

you should not name your file with the same name as your library. in this case change your file name to something else to solve the error.