【问题标题】:error while importing Tkinter in python [duplicate]在python中导入Tkinter时出错[重复]
【发布时间】:2011-11-13 18:08:36
【问题描述】:

导入 Tkinter 时出现以下错误:

Python 2.7.1 (r271:86832, Jun 11 2011, 11:34:27) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/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
>>> 

我该怎么办?

【问题讨论】:

    标签: python


    【解决方案1】:

    可能只安装 Tkinter - 如果你有一个基于 Debian 的发行版,也许 apt-get install python-tk 会这样做。可能是 python3-tk 或其他发行版的其他名称。

    【讨论】:

      【解决方案2】:

      您可以尝试这样做

      from tkinter import *
      

      我不知道为什么,但这似乎对我有用,它只是意味着从 tkinter 全部导入。 他们在 python 3.5 中将其更改为小写 t 的另一件事。只是为了将来的知识。

      【讨论】:

        猜你喜欢
        • 2011-11-21
        • 2013-06-26
        • 2013-05-10
        • 1970-01-01
        • 1970-01-01
        • 2018-01-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多