1

I'm using PySide2 and matplotlib. When plt.subplots is executed, this error is raised and the application is terminated.

I'm currently using matplotlib.use('Qt5Agg'), but does not make any difference.

I'm using Anaconda with Python 3.6.5.

Any hint?

EDIT: Added minimal example

def plot():
    import pandas as pd
    import matplotlib
    matplotlib.use('Qt5Agg')
    #matplotlib.rcParams['backend.qt5']='PySide2'
    import matplotlib.pyplot as plt

    fig, (ax, ax1) = plt.subplots(2, 1, sharex=True)


if __name__ == '__main__':
    import sys
    from PySide2.QtWidgets import QApplication
    from ib_insync import util

    util.useQt()
    app = QApplication(sys.argv)
    plot()
Roman Rdgz
  • 12,836
  • 41
  • 131
  • 207
  • please provide a [mcve] – eyllanesc Oct 09 '18 at 22:08
  • it seems that the dlls are not compatible between Qt 5.11.1 and 5.11.2 – eyllanesc Oct 09 '18 at 22:10
  • @eyllanesc I also understand that but, why is matplotlib making use of ANY version of Qt? (supposing that it is inded matplotlib the one with 5.11.2). Would updating pyside2 fix the problem? – Roman Rdgz Oct 10 '18 at 13:06
  • Not only is matplotlib but any software that depends on certain versions of library since each version adds and removes classes, methods or functions, try updating the version of PySide2. – eyllanesc Oct 10 '18 at 13:32
  • You may try something like: https://stackoverflow.com/a/51563781/2741329. That is, remove conda Qt5 and use the official PySide2 wheel from PyPi. It works for me. – gmas80 Oct 27 '18 at 14:29

1 Answers1

0

Try clearing out any Qt related environment variables:

export QT_HOME=""
export QT_QPA_PLATFORM_PLUGIN_PATH=""
Jack M
  • 4,769
  • 6
  • 43
  • 67