简体   繁体   中英

I get this error when importing Tkinter in python

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM