Python 属性错误:'_tkinter.tkapp';对象没有属性';Tcl错误';
我正在尝试在tkinter窗口中嵌入matplotlib图形,并在主代码中使用它之前使用以下代码作为基础 如果运行下面的代码,则会出现以下错误: AttributeError:“\u tkinter.tkapp”对象没有属性“TclError” 代码:Python 属性错误:'_tkinter.tkapp';对象没有属性';Tcl错误';,python,matplotlib,tkinter,Python,Matplotlib,Tkinter,我正在尝试在tkinter窗口中嵌入matplotlib图形,并在主代码中使用它之前使用以下代码作为基础 如果运行下面的代码,则会出现以下错误: AttributeError:“\u tkinter.tkapp”对象没有属性“TclError” 代码: 有人能帮我解决这个错误吗?然而,对于不同的属性(“choice”、“getitems”、“text”、“PassCheck”等),我发现了关于堆栈溢出的类似问题。谢谢 将导入matplotlib作为mpl替换为: from matplotlib
有人能帮我解决这个错误吗?然而,对于不同的属性(“choice”、“getitems”、“text”、“PassCheck”等),我发现了关于堆栈溢出的类似问题。谢谢 将
导入matplotlib作为mpl
替换为:
from matplotlib.figure import Figure
然后将import matplotlib.backends.tkagg替换为tkagg
from matplotlib.backends import _backend_tk
最后,替换该行:
tkagg.blit(photo, figure_canvas_agg.get_renderer()._renderer, colormode=2)
与:
看看它是否有效。
您可能希望引用此合并请求:替换
将matplotlib导入为mpl
:
from matplotlib.figure import Figure
然后将import matplotlib.backends.tkagg替换为tkagg
from matplotlib.backends import _backend_tk
最后,替换该行:
tkagg.blit(photo, figure_canvas_agg.get_renderer()._renderer, colormode=2)
与:
看看它是否有效。
您可能需要引用此合并请求:请不要忘记更新投票:d请不要忘记更新投票:d谢谢,它成功了。由于我以后使用了
mpl
,所以我保留了import matplotlib作为mpl
的功能。谢谢,它成功了。由于以后使用了mpl
,所以我保留了import matplotlib作为mpl
。