MatplotLib (TKinter) + OpenCV crashing in Python 3 MatplotLib (TKinter) + OpenCV crashing in Python 3 tkinter tkinter

MatplotLib (TKinter) + OpenCV crashing in Python 3


Not sure if it will help you guys/girls, but I ran into similar issues trying to embed matplotlib into a kivy application (Also on a mac), after a few hours of googling, rewriting classes, uninstalls and reinstalls, and at one point even attempting to plot using a different library entirely. I found the simplest solution was to to bin off the ('TkAgg') backend entirely as it doesn't seem to play nice and then explicitly declare the OSX one

import matplotlibmatplotlib.use("MacOSX")import matplotlib.pyplot as plt

Worked for me, Occams razor and all that I suppose, good luck!


No idea about matplotlib, but I can imagine that there could be a problem with window management. Try this:

cv2.imshow('test', im)cv2.waitKey(1)cv2.destroyWindow('test')

At least this is the right way of treating already opened cv2.imshow() windows when they are not used anymore.