Skip to content

Commit 62b5d78

Browse files
committed
Merge pull request #4548 from efiring/pyqt_error_msg
MNT: supply more helpful message when no pyqt or pyside is found
2 parents 32a3292 + 56b71d0 commit 62b5d78

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/matplotlib/backends/qt_compat.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
except ImportError:
6666
# Try using PySide
6767
QT_API = QT_API_PYSIDE
68+
cond = ("Could not import sip; falling back on PySide\n"
69+
"in place of PyQt4 or PyQt5.\n")
70+
verbose.report(cond, 'helpful')
6871

6972
if _sip_imported:
7073
if QT_API == QT_API_PYQTv2:
@@ -123,7 +126,13 @@ def _getSaveFileName(*args, **kwargs):
123126
__version__ = QtCore.PYQT_VERSION_STR
124127

125128
else: # try importing pyside
126-
from PySide import QtCore, QtGui, __version__, __version_info__
129+
try:
130+
from PySide import QtCore, QtGui, __version__, __version_info__
131+
except ImportError:
132+
raise ImportError(
133+
"Matplotlib qt-based backends require an external PyQt4, PyQt5,\n"
134+
"or PySide package to be installed, but it was not found.")
135+
127136
if __version_info__ < (1, 0, 3):
128137
raise ImportError(
129138
"Matplotlib backend_qt4 and backend_qt4agg require PySide >=1.0.3")

0 commit comments

Comments
 (0)