Search code examples
pythonpython-3.xmatplotlibpyside2

Deallocation error of Matplotlib embeded in Pyside 2


I am executing this example file for matplotlib and I am getting the following error while exiting the mainwindow normally.

Fatal Python error: deallocating None

I have only changed the following lines, because i wanted to use PySide2 instead of PyQt.

Original:

# Make sure that we are using QT5
matplotlib.use('Qt5Agg')
from PyQt5 import QtCore, QtWidgets

New:

# Make sure that we are using QT5
matplotlib.use('Qt5Agg')
matplotlib.rcParams['backend.qt5']='PySide2'
from PySide2 import QtCore, QtWidgets

The program otherwise runs perfectly, it just crashes when i close it, which is a bit irritating.

My environment consists of:

  • Python 3.6.4
  • PySide2 5.6.0a1
  • MatplotLib 2.2.2

Any ideas?


Solution

  • Refer to this post https://stackoverflow.com/a/49712824/6704496, it appears a not up-to-date version bug. Please download the newest wheel http://download.qt.io/snapshots/ci/pyside/5.9/latest/.