我在尝试使用 Mac 中的 Enthough-Canopy 编译简单的 tkinter gui 时遇到问题。这是我要编译的代码:
from Tkinter import *
root= Tk();
root.title('Toplevel')
Label(root,text='This is the Toplevel').pack(pady=10)
root.mainloop()
这是我收到的消息:
ImportError Traceback (most recent call last)
/Applications/Canopy.app/appdata/canopy-1.0.0.1160.macosx-
x86_64/Canopy.app/Contents/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in
execfile(fname, *where)
181 else:
182 filename = fname
--> 183 __builtin__.execfile(filename, *where)
/var/folders/m1/70f55r290cz7j_sjc010k0n00000gn/T/tmp1gLNQA.py in <module>()
----> 1 from Tkinter import *
2
3 root= Tk();
4
5 root.title('Toplevel')
/Applications/Canopy.app/appdata/canopy-1.0.0.1160.macosx-
x86_64/Canopy.app/Contents/lib/python2.7/lib-tk/Tkinter.py in <module>()
37 # Attempt to configure Tcl/Tk without requiring PATH
38 import FixTk
---> 39 import _tkinter # If this fails your Python may not be configured for Tk
40 tkinter = _tkinter # b/w compat for export
41 TclError = _tkinter.TclError
ImportError: dlopen(/Applications/Canopy.app/appdata/canopy-1.0.0.1160.macosx-
x86_64/Canopy.app/Contents/lib/python2.7/lib-dynload/_tkinter.so, 2): Library not loaded:
/Library/Frameworks/Python.framework/Versions/111.222.33344/lib/libtcl8.5.dylib
Referenced from: /Applications/Canopy.app/appdata/canopy-1.0.0.1160.macosx-
x86_64/Canopy.app/Contents/lib/python2.7/lib-dynload/_tkinter.so
Reason: image not found
主要问题是 TK 或 TCL,但它已经安装并且运行良好(代码在 Aptana studio 3 中运行良好),但是当我尝试在 Canopy 中运行它时它失败了。
感谢您的时间和支持