wxPython 4.1.1 + matplotlib 3.3.3 problem with add_subplot

Hi there,
i dont know if this is a known problem, but after updating matplotlib and wxpython to the newest versions i have some problems in my code which worked fine before the update.

  • When i start my code from the IDE (Spyder) everything is working fine
  • When converting to an EXE it crashes at self.axes = self.figure.add_subplot(111) without any error message
  • it worked fine in previous versions

Any ideas how to solve this?

import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas

class WeeklyOrderGraph(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.figure = self.matplotlib_figure = Figure()
        print("Until here all fine")
        self.axes = self.figure.add_subplot(111) 
        print("Before this it crashes")
        self.canvas = FigureCanvas(self, 1, self.figure)  
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.EXPAND)         

Depending on which EXE tool you are using there may be an error log somewhere, or a way to turn it on. If not then I would suggest to set sys.stderr to a writable file, at least while debugging. That way if there is a traceback happening then you’ll be able to see what it is.

Otherwise, a small runnable sample would help us help you.