Why do i get this error in tkinter - Python

0 votes
This is my code:

from tkinter import *

root = Tk()

hw = Label(root, text="Hello World!")

hw.pack()

root.mainloop()

This is the error i get:

Traceback (most recent call last):
  File "/Users/lorisruegg/Documents/Python/tkinter.py", line 1, in <module>
    from tkinter import *
  File "/Users/lorisruegg/Documents/Python/tkinter.py", line 3, in <module>
    root = Tk()
NameError: name 'Tk' is not defined
Oct 10, 2021 in Python by LogizTV
• 120 points
798 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
1 answer

In NumPy how do I get the maximum of subsets? Python

You can use np.maximum.reduceat: >>> _, idx = np.unique(g, ...READ MORE

answered Nov 9, 2018 in Python by Nymeria
• 3,560 points
1,593 views
0 votes
1 answer

Why am I getting a error when I am printing two different data types in python?

different data type is being used. that ...READ MORE

answered Mar 6, 2019 in Python by Mohammad
• 3,230 points
1,039 views
0 votes
1 answer

How do I get a random number with a float range in python?

Use random.uniform(a, b): Returns a random floating point ...READ MORE

answered May 27, 2019 in Python by Kiran
992 views
0 votes
1 answer

What to do when I get and error saying python not recognized as internal or external command?

You need to set up the path ...READ MORE

answered May 28, 2019 in Python by Fata
• 1,050 points
2,466 views
+1 vote
4 answers

How do i resolve the "unexpected indent" error in python?

Look for the whitespaces which are not ...READ MORE

answered Aug 2, 2019 in Python by Mohammad
• 3,230 points
137,450 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP