【问题标题】:Python 2.7.10_2: No module named _tkinterPython 2.7.10_2:没有名为 _tkinter 的模块
【发布时间】:2015-10-30 04:10:39
【问题描述】:

我使用 tkinter 编写了一个 Python 脚本。然而今天,在更新homebrew 后,我收到以下错误:

没有名为 _tkinter 的模块

当我尝试导入 tkinter。

交互式终端如下所示:

>>> import Tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/lib-tk/Tkinter.py"line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
>>> 

当我尝试导入 _tkinter 时,我得到了这个:

ImportError: No module named _tkinter

【问题讨论】:

  • 那么...你有什么问题?
  • 如何修复错误? @亚历杭德罗
  • 查看这些帖子:stackoverflow.com/questions/5459444/…stackoverflow.com/questions/6320954/…。当您遇到此类特定错误或异常时,您应该准确复制回溯的关键部分,在这种情况下为ImportError: No module named _tkinter,并将其粘贴到google搜索框上,然后单击Google Search,通常您很幸运; )

标签: python macos python-2.7 tkinter


【解决方案1】:

Tkinter 是 Python 中默认提供的 GUI 库。如果您无法调用 Tkinter,则意味着您的 python 安装已损坏。重新安装你的 python 应该可以解决它。

【讨论】:

  • 我相信默认的 OS X Python 不包含 Tkinter?
  • 我不这么认为。看看Wiki LinkTkinter 包含在 Windows 和 mac 安装的 python 中。
  • 应该提到我已经尝试过几次,但没有任何运气。
  • @Kupiakos Mac OS X 的默认 Python 发行版包括 tkinter!
猜你喜欢
  • 1970-01-01
  • 2021-04-09
  • 2020-10-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多