BhallaLab / moose-gui

PyQt frontend (chemical signaling and neuronal simulations) for MOOSE
1 stars 5 forks source link

Import error with new matplotib which uses `PyQt5` #13

Open dilawar opened 8 years ago

dilawar commented 8 years ago

If python-matplotlib-qt5 or python-matplotlib-qtshared package is installed, moosegui won't launch. The trace-back is following:

Traceback (most recent call last):
  File "mgui.py", line 1194, in <module>
    main()
  File "mgui.py", line 1178, in main
    mWindow =  MWindow()
  File "mgui.py", line 177, in __init__
    self.setPlugin('default', '/')
  File "mgui.py", line 460, in setPlugin
    self.plugin = self.loadPluginClass(str(name))(str(root), self)
  File "mgui.py", line 412, in loadPluginClass
    pluginModule = self.loadPluginModule(name, re=re)
  File "mgui.py", line 364, in loadPluginModule
    module = imp.load_module(name, fp, pathname, description)
  File "/usr/lib/moose/gui/plugins/default.py", line 89, in <module>
    from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt4agg.py", line 18, in <module>
    from .backend_qt5agg import FigureCanvasQTAggBase as _FigureCanvasQTAggBase
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 15, in <module>
    from .backend_qt5 import QtCore
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 27, in <module>
    import matplotlib.backends.qt_editor.figureoptions as figureoptions
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/qt_editor/figureoptions.py", line 17, in <module>
    import matplotlib.backends.qt_editor.formlayout as formlayout
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/qt_editor/formlayout.py", line 58, in <module>
    from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/qt_compat.py", line 114, in <module>
    from PyQt5 import QtCore, QtGui, QtWidgets
RuntimeError: the PyQt5.QtCore module failed to register with the sip module

To fix it, make sure that matplotlib uses PyQt4 and an appropriate back-end is initialized. Otherwise you might run into following:

/usr/lib/python2.7/site-packages/moose/utils.py:35: UserWarning: Failed to importing plotting utilities: No module named backend_qt5agg
  warnings.warn("Failed to importing plotting utilities: %s" % e)
Traceback (most recent call last):
  File "mgui.py", line 1194, in <module>
    main()
  File "mgui.py", line 1178, in main
    mWindow =  MWindow()
  File "mgui.py", line 177, in __init__
    self.setPlugin('default', '/')
  File "mgui.py", line 460, in setPlugin
    self.plugin = self.loadPluginClass(str(name))(str(root), self)
  File "mgui.py", line 412, in loadPluginClass
    pluginModule = self.loadPluginModule(name, re=re)
  File "mgui.py", line 364, in loadPluginModule
    module = imp.load_module(name, fp, pathname, description)
  File "/usr/lib/moose/gui/plugins/default.py", line 89, in <module>
    from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
ImportError: No module named backend_qt4agg

It might need some attention before next release.

OS: OpenSuSE-Leap_42.1

dilawar commented 8 years ago

Perhaps, it should best be handled at packaging level. If packages is installed, this should never happen. I should search for python-matplotlib-qt4 in dependency instead of python-matplotlib-qt.

If would be good, it gui can also use PyQt5. That would make packages more portable to newer versions.