将 Matplotlib Graph 嵌入到 Tkinter 在 Python 3.5 上崩溃 [英] Embeded Matplotlib Graph into Tkinter crashes on Python 3.5

查看:82
本文介绍了将 Matplotlib Graph 嵌入到 Tkinter 在 Python 3.5 上崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将Python 2.7脚本移植到Python 3.5时,此代码在Windows Anaconda 2.4.1(64位)中崩溃:

While porting Python 2.7 script to Python 3.5, this code crashes in Windows Anaconda 2.4.1 (64-bit):

import tkinter as Tk
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

root = Tk.Tk()

fig = plt.figure()
canvas = FigureCanvasTkAgg(fig, master=root)
canvas.get_tk_widget().place(relx=0.02, rely=0.14, relheight=0.83, relwidth=0.96)

Tk.mainloop()

根本原因是 get_tk_widget().place() 方法.Windows事件视图提供了以下信息:

The root cause is get_tk_widget().place() method. Windows Event View provides this info:

Faulting application name: python.exe, version: 3.5.1150.1013, time stamp: 0x5665f370
Faulting module name: tcl86t.dll, version: 8.6.2.4, time stamp: 0x55dbf93d
Exception code: 0xc0000005
Fault offset: 0x00000000000165a9
Faulting process id: 0x26a4
Faulting application start time: 0x01d1364cdb6d7ba9
Faulting application path: C:\Anaconda3\python.exe
Faulting module path: C:\Anaconda3\DLLs\tcl86t.dll

这是一个众所周知的错误吗?如何解决这个问题?

Is it a well-known bug? How to fix this?

推荐答案

我只是通过 pip 重新安装 matplotlib 来解决:

I figure out just by reinstalling matplotlib via pip:

pip uninstall matplotlib
pip install matplotlib

这篇关于将 Matplotlib Graph 嵌入到 Tkinter 在 Python 3.5 上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆