I'm trying to complete this tutorial https://likegeeks.com/python-gui-examples-tkinter-tutorial/amp/.
I have the following code written
from tkinter import *
window = Tk()
window.title('Welcome to LikeGeeks app')
window.mainloop()
I have run the command
sudo apt install python3-tk
However I am still getting the following error:
NameError: name 'Tk' is not defined
The Python version on my machine is Python 3.6.5.
Turtle graphics work fine.
edit: I renamed the file from tkinter.py to test.py and I got this error message
Traceback (most recent call last):
File "test.py", line 1, in <module>
from tkinter import *
ImportError: bad magic number in 'tkinter': b'\x03\xf3\r\n'
python3
withpython2
by typingpython 3 scriptname.py
. Instead remove the space betweenpython
and3
:python3 scriptname.py
. Otherwise see this answer stackoverflow.com/questions/514371/…