-2

I am trying to learn Tkinter in python but when I try to import it, it gives me this error:

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    from tkinter import *
ImportError: No module named tkinter

I don't know what to do, can someone please help? Thanks.

1 Answers1

1

Depending on what version of Python you are using, you need to import tkinter in a different way. In python 2, the code is this: from Tkinter import *. In Python 3, you should use from tkinter import *.

The difference is that the first letter in tkinter is capitalized in Python 2, while in Python 3 it is all lowercase.

If you are not sure what version of Python you are using, open the Python Shell and it will show you.

Justin Cheng
  • 153
  • 1
  • 8
  • I know, I am using python 3.8. I import it like 'from tkinter import *' but it gives me the same error. – SpiderDev_m8 May 21 '20 at 02:23
  • Try this link: https://stackoverflow.com/questions/25905540/importerror-no-module-named-tkinter?rq=1.And if it doesn't work then look the the right on the "Linked" category and you'll find other similar questions. – Justin Cheng May 22 '20 at 01:09