Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 56b71d0

Browse filesBrowse files
committed
qt_compat: supply more helpful message when no pyqt or pyside is found
Without this change, if the backend is set to Qt4Agg but there is no pyqt or pyside package installed, the import error only mentions the absence of PySide.
1 parent 32a3292 commit 56b71d0
Copy full SHA for 56b71d0

File tree

Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed

‎lib/matplotlib/backends/qt_compat.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/qt_compat.py
+10-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.