安装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:Python27liblib-tkTkinter.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.
这里有一个对我有效的解决方法。我复制了两个目录:tcl8.5
和tk8.5
,从C:Python27tcl
复制到C:Python27lib
,然后代码运行时没有任何错误。