Introduced Matplotlib graph in Tkinter crashes in Python 3.5

When porting a Python 2.7 script to Python 3.5, this code crashes on 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()

The main reason is the method get_tk_widget().place(). Windows Event View provides this information:

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 this a known bug? How to fix it?

+4
source share
1 answer

I find out by simply reinstalling matplotlib via pip:

pip uninstall matplotlib
pip install matplotlib
+4
source

Source: https://habr.com/ru/post/1619823/


All Articles