【问题标题】:Same Program Runs Fine when ran from IDLE but not when ran directly从 IDE 运行时,相同的程序运行良好,但直接运行时运行良好
【发布时间】:2013-07-27 01:56:34
【问题描述】:

我在 python 上编写了一个基于 Tkinter 的小型 GUI 应用程序。使用 IDLE 运行时运行良好,但直接运行时显示 moduleError。我在窗户上。直接运行它意味着双击 .py 文件。这是代码的链接。我在 PATH 环境变量中附加了 python 的路径

http://codepad.org/ezxcpi7Y

还有错误图片:

为什么我会收到这个错误?请帮忙

【问题讨论】:

  • 首先想到的是:python 路径是什么?从 IDLE 和 cmd 中打印出 sys.path 路径并进行比较
  • 请注意,代码中有一行...tkinter.mesagebox.showinfo....
  • 这不会引起问题

标签: python tkinter


【解决方案1】:

你需要import tkinter.messagebox

IDLE(writen in tk) 在 tkinter 中导入这个模块(python 不会两次导入模块)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多