1
我在使用Mac中的Enthough-Canopy編譯一個簡單的tkinter gui時遇到問題。這是我試圖編譯代碼:Enthought-Canopy for mac中與Tkinter衝突
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工作室3)中表現良好,但是當我嘗試在Canopy中運行時失敗。
感謝您的時間和支持
Hector,jweaver的答案應該是正確的。如果屬實,請說出來並將問題標記爲已回答(SO協議)。謝謝! –