idle-python3.2 未启动:抱怨 NameError:未定义名称“Tk" [英] idle-python3.2 not starting: complains of NameError: name 'Tk' is not defined

查看:79
本文介绍了idle-python3.2 未启动:抱怨 NameError:未定义名称“Tk"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 linux mint 13

running linux mint 13

idle-python3.2 以前在终端上工作过,现在不行了.从终端调用 idle-python3.2 会引发以下错误,但我可以通过双击脚本来运行 Idle!

idle-python3.2 did work from the terminal before, now it does not. Calling idle-python3.2 from the terminal throws the error below BUT I can run Idle by double clicking on the script!

这是打破一切的非常简单的脚本(?)http://pastebin.com/pP9An3UUFWIW,该脚本似乎也不起作用(运行它时什么也没发生).

Here's the very simple script that broke it all(?) http://pastebin.com/pP9An3UU FWIW, the script does not appear to work either (nothing happens when I run it).

这是尝试从终端运行 Idle3.2 时终端中的错误:

Here's the error in the terminal when trying to run Idle3.2 from the terminal:

File "tkinter.py", line 2, in <module>
    tk = Tk()
NameError: name 'Tk' is not defined

这是完整的错误http://pastebin.com/J5AfAQyV

我知道默认情况下未安装 tkinter...但它已安装

I know tkinter is not installed by default... but it IS installed

python3-tk is already the newest version.
python3-tk set to manually installed.

我已经检查了系统监视器并杀死了所有在后台运行的明显 python 实例.

I've checked the system monitor and killed all obvious python instances running in the background.

但是,仍然没有快乐.

这是错误的视频:http://youtu.be/oCLOJR2rktI

感谢您对修复问题的帮助.

Your help for a fix is appreciated.

推荐答案

听起来您要么 a) 将您的小测试程序命名为tkinter.py",要么 b) 在同一目录中有另一个名为tkinter.py"的文件.py".如果是这种情况,当您执行 from tkinter import * 时,您不是导入真正的 tkinter,而是导入本地文件.

It sounds like you either a) named your little test program "tkinter.py", or b) you have another file in the same directory named "tkinter.py". If that is the case, when you do from tkinter import *, you are not importing the real tkinter but rather importing the local file.

如果您将文件命名为tkinter.py",请将其重命名.此外,如果有名为tkinter.pyc"的文件,请将其删除.

If you named your file "tkinter.py", rename it. Also, if there is a file named "tkinter.pyc", remove it.

这篇关于idle-python3.2 未启动:抱怨 NameError:未定义名称“Tk"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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