-1

Everything looks OK if I just run the scripts in Pycharm. It will show the plots. However, after I convert the scripts into exe file. It can save the plots, but it won't show any plot. The most weird thing is that it will re-open another exe file.

Thanks, really appreciate if someone know the root cause.

Hao
  • 21
  • 2
  • 1
    Somehow it is fixed by 1) adding matplotlib.use('WXagg') 2) not using multiprocessing. – Hao Oct 04 '17 at 05:42
  • I am pretty sure `WXagg` is required to embed matplotlib in wxPython. I suspect the tool you were using to create your executable wasn't picking up everything it needed from matplotlib. – Mike Driscoll Oct 04 '17 at 14:08

1 Answers1

0

As mentioned in the comment, calling matplotlib.use('WXAgg') is necessary, but there is another step: matplotlib has a backend object you need to import manually to paint a figure in wx: matplotlib.backends.backend_wxagg. This creates a figure canvas object inside a wx.panel of your choosing.

This answer contains a nice example. Furthermore, you can look up the actual object in matplotlib website, then proceed to look at their artist tutorial, which covers how to use matplotlib in applications rather well.

P.Diddy
  • 34
  • 6