BU-hammerTeam/PyHammer

matplotlib import fails in eyecheck.py

ctheissen opened this issue · 2 comments

I get the following issue (on a fairly new mac) when running the test case:

Traceback (most recent call last):
File "pyhammer.py", line 12, in <module> from eyecheck import Eyecheck
File "/Users/Chris/repos/PyHammer/eyecheck.py", line 8, in <module> import matplotlib.pyplot as plt
File "/usr/local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in <module> _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup globals(),locals(),[backend_name],0)
File "/usr/local/lib/python3.6/site-packages/matplotlib/backends/backend_qt4agg.py", line 18, in <module> from .backend_qt5agg import FigureCanvasQTAggBase as _FigureCanvasQTAggBase
File "/usr/local/lib/python3.6/site-packages/matplotlib/backends/backend_qt5agg.py", line 16, in <module> from .backend_qt5 import QtCore
File "/usr/local/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 26, in <module> import matplotlib.backends.qt_editor.figureoptions as figureoptions
File "/usr/local/lib/python3.6/site-packages/matplotlib/backends/qt_editor/figureoptions.py", line 20, in <module> import matplotlib.backends.qt_editor.formlayout as formlayout
File "/usr/local/lib/python3.6/site-packages/matplotlib/backends/qt_editor/formlayout.py", line 56, in <module> from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
File "/usr/local/lib/python3.6/site-packages/matplotlib/backends/qt_compat.py", line 137, in <module> from PyQt4 import QtCore, QtGui
ModuleNotFoundError: No module named 'PyQt4'

The issue seems to be that newer macs use PyQt5 instead of PyQt4. The fix was to change matplotlib.use('Qt4Agg') to matplotlib.use('Qt5Agg')

Just thought you might want to add a check for which PyQt is installed.

Thanks for letting us know. It seems Python 3.6 dropped support for PyQt4. Code now searches for both PyQt4 and PyQt5.