无法使用Canopy导入Tkinter

时间:2013-04-30 12:20:07

标签: python enthought canopy

我尝试使用Canopy导入Tk失败:

In [1]: import Tkinter
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-a0c812564da3> in <module>()
----> 1 import Tkinter

/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

$ ls -l /Applications/Canopy.app/appdata/canopy-1.0.0.1160.macosx-x86_64/Canopy.app/Contents/lib/python2.7/lib-dynload/_tkinter.so
-rwxr-xr-x@ 1 cassio  admin  66184 Mar 25 17:54
/Applications/Canopy.app/appdata/canopy-1.0.0.1160.macosx-x86_64/Canopy.app/Contents/lib/python2.7/lib-dynload/_tkinter.so

$ ls -l /Library/Frameworks/Python.framework/Versions/111.222.33344/lib/libtcl8.5.dylib
ls: /Library/Frameworks/Python.framework/Versions/111.222.33344/lib/libtcl8.5.dylib:
No such file or directory

我认为Tk / Tcl预先安装了python。 我怎样才能让它发挥作用?

2 个答案:

答案 0 :(得分:0)

我遇到了同样的问题:Tk import failed。但是当它没有失败时 - 没有显示任何东西,过了一段时间Python内核就死了。

我不知道如何解决它,但从终端运行帮助(我使用OS X 10.6.8)。我刚输入(名为test.py的文件)

$python test.py

答案 1 :(得分:0)

实际上,来自Enthought的Jonathan March通过在Enthought知识库网站上发布workaround来回应此问题,该网站涉及更改某些动态库并更改默认的UI后端。