导入错误:没有名为tkinter的模块 [英] Import error: No module named tkinter

查看:493
本文介绍了导入错误:没有名为tkinter的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我制作的计算器构建图形,但是我收到一条错误,说没有模块tkinter。如何修复我的代码以便正确导入tkinter?

I'm attempting to build graphics for a calculator I made, but I'm getting an error saying that there's no module tkinter. How do I fix my code so that it correctly imports tkinter?

import sys
from tkinter import*

root = Tk()
frame = Frame(root)
frame.pack()

root.title('Calculator')

root.mainloop()


推荐答案

检查python是什么您拥有的版本

Check what python version you have

如果您有来自tkinter的python 3x:

If you have python 3x:

from tkinter import *

如果你有python 2x

If you have python 2x

from Tkinter import *

如果两者都不起作用,重新安装tkinter。

If both of those do not work, reinstall tkinter.

点击此处安装tkinter

这篇关于导入错误:没有名为tkinter的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆