这个问题类似于this other question .
当我在 Mac OS X 上运行以下代码时(它在 Windows 上运行良好):
import Tix
root = Tix.Tk()
我收到以下错误消息:
Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tix.py", line 221, in init self.tk.eval('package require Tix') _tkinter.TclError: can't find package Tix
Python 文档描述了 issue ,但下面的答案对我没有帮助:
If this fails, you have a Tk installation problem which must be resolved before proceeding. Use the environment variable TIX_LIBRARY to point to the installed Tix library directory, and make sure you have the dynamic object library (tix8183.dll or libtix8183.so) in the same directory that contains your Tk dynamic object library (tk8183.dll or libtk8183.so). The directory with the dynamic object library should also have a file called pkgIndex.tcl (case sensitive), which contains the line:
package ifneeded Tix 8.1 [list load "[file join $dir tix8183.dll]" Tix]
如果有人遇到此错误并找到解决方法,请告诉我。
请您参考如下方法:
基于 Terry 对 Python.org 用户组的询问:
如果您使用的是 64 位 Mac OSX,那您就不太走运了。
如果您碰巧有 32 位运行并且安装了 Tcl,您可以简单地使用
teacup安装Tix(它是类似于pip并且它随Tcl) 一起安装sudo teacup install TixTix过时(小部件样式和文档维护),最好使用Ttk.
