简体   繁体   中英

ImportError: No module named 'Tkinter''

Looking at this link, when I install Python it says Tcl/Tk/Tkinter will also install, but when I run a game in Python, I get an import error. I have my usual import statements as well, but it's still not working. I also looked at this very similar problem, but the answer isn't working for me.

import simplegui
import random
from tkinter import *

假设您使用的是 Python 3.x,程序必须使用python3 my-program.py (而不是python my-program.py )运行。

I am assuming you are using python2.

Try this

from Tkinter import *

You are putting wrong name for module. This will work.

EDIT AFTER COMMENT

For python3 install this python3-tk and your code will work.

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