【发布时间】:2014-10-06 20:41:17
【问题描述】:
几天后,我回到我的电脑前,发现我的绘图脚本不再工作,尽管没有对绘图代码或计算机库进行任何更改。我决定进行调查,here 中的示例脚本不再有效并引发此错误
objc[34475]: Class TKApplication is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.6/Tk. One of the two will be used. Which one is undefined.
objc[34475]: Class TKMenu is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.6/Tk. One of the two will be used. Which one is undefined.
objc[34475]: Class TKContentView is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.6/Tk. One of the two will be used. Which one is undefined.
objc[34475]: Class TKWindow is implemented in both /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.6/Tk. One of the two will be used. Which one is undefined.
在下面提到的导入和以下致命错误 uport 运行 Tk.Tk()
Traceback (most recent call last):
File "/Users/username/Desktop/Projects/name/test.py", line 20, in <module>
root = Tk.Tk()
File "/usr/local/Cellar/python3/3.3.3/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/__init__.py", line 1789, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError
如果我在虚拟环境中工作,我很困惑为什么它指向我的 Brewed(如果这有帮助,我在 Os X 上)python。值得注意的是,Tkinter 和 Matplotlib 是分开工作的,就这么一行
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
这会破坏东西。
EDIT1:我厌倦了重新安装 Tcl、python 和 virtualenv。没有解决问题:(
EDIT2: 在 python2 (innsted of 3) 解释器中运行相同的东西。错误更详细。
/Library/Frameworks/Tk.framework/Resources/Scripts/tk.tcl: version conflict for package "Tcl": have 8.5.9, need 8.6
version conflict for package "Tcl": have 8.5.9, need 8.6
while executing
"package require Tcl 8.6"
(file "/Library/Frameworks/Tk.framework/Resources/Scripts/tk.tcl" line 14)
invoked from within
"source /Library/Frameworks/Tk.framework/Resources/Scripts/tk.tcl"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list source $file]"
This probably means that tk wasn't installed properly.
好的,所以问题与 Tcl 的事情有关。我没有碰过它,它以前工作过。
EDIT3:尝试重新安装ActiveTcl - 没有改变任何东西
EDIT4:在/System/Library/Frameworks/Tk.framework/Versions/ 下我安装了 Tk 版本 8,5 和 8.4
/Library/Frameworks/Tk.framework/Versions/下我安装的是8.6版。
我尝试禁用 8.6 版以反映脚本在另一台计算机上运行的配置。收到此错误:
ImportError: dlopen(/Users/mik/Desktop/Projects/ODE/virtenv/lib/python3.4/site-packages/matplotlib/backends/_tkagg.so, 2): Library not loaded: /Library/Frameworks/Tcl.framework/Versions/8.6/Tcl
Referenced from: /Users/mik/Desktop/Projects/ODE/virtenv/lib/python3.4/site-packages/matplotlib/backends/_tkagg.so
Reason: image not found
两台计算机都使用相同的 Python 版本 (3.4.1) 和相同的 matplotlib 版本 (1.3.1)。有没有办法指定 matplotlib 使用哪个 Tk/Tcl 版本?
编辑 6:我使用 Time Machine 验证自上次运行脚本以来没有任何 Tk/Tcl veriosn 文件发生更改。
编辑 7:还有一个解决方案:
将 matplotlib 文件夹从工作计算机的站点包复制到显示这些错误的文件夹修复了问题。今后如何设置matplotlib使用的tcl版本,不胜感激。
【问题讨论】:
标签: python macros matplotlib tkinter