【问题标题】:Tkinter code throws exception in latest ActivePythonTkinter 代码在最新的 ActivePython 中引发异常
【发布时间】:2016-05-04 21:06:26
【问题描述】:

安装 ActivePython 2.7.10.12 后,尝试创建 Tkinter 实例时,出现以下错误:

ActivePython 2.7.10.12 (ActiveState Software Inc.) based on
Python 2.7.10 (default, Aug 21 2015, 12:07:58) [MSC v.1500 64 bit (AMD64)] on wi
n32
Type "help", "copyright", "credits" or "license" for more information.
>>> from Tkinter import Tk
>>> root = Tk()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\lib-tk\Tkinter.py", line 1814, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, want
objects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
    C:/Python27/lib/tcl8.5 C:/lib/tcl8.5 C:/lib/tcl8.5 C:/library C:/library C:/
tcl8.5.18/library C:/tcl8.5.18/library



This probably means that Tcl wasn't installed properly.

【问题讨论】:

    标签: python windows python-2.7 tkinter activepython


    【解决方案1】:

    这是一个对我有用的解决方法。我复制了2个目录:tcl8.5tk8.5,从C:\Python27\tcl复制到C:\Python27\lib,然后代码运行没有任何错误。

    【讨论】:

    • MS Windows 是否支持符号链接?当 tcl/tk 更新时,它将在 C:\Python27\tcl 中更新,因此您的程序仍将使用旧的(复制的)版本(可能会或可能不会导致问题)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-06
    • 2021-10-04
    相关资源
    最近更新 更多