From f3f85ed204de9a9e959e20ada13e34c80a0030e2 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 28 Apr 2021 02:40:52 -0400 Subject: [PATCH] Ignore errors for sip with no setapi. Apparently, this happens (see #20040 and related issues) sporadically. We don't care if we can't change the sip API version (if it's already been set), so also stop caring if the `setapi` function doesn't exist. This should simply cause the Qt4 backend to fail correctly later with an `ImportError` instead, and thus fall back to the next backend candidate. Fixes #20040. --- lib/matplotlib/backends/qt_compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/backends/qt_compat.py b/lib/matplotlib/backends/qt_compat.py index 26ddcc46c27e..ae72847e3187 100644 --- a/lib/matplotlib/backends/qt_compat.py +++ b/lib/matplotlib/backends/qt_compat.py @@ -117,7 +117,7 @@ def _setup_pyqt4_internal(api): for _sip_api in _sip_apis: try: sip.setapi(_sip_api, api) - except ValueError: + except (AttributeError, ValueError): pass from PyQt4 import QtCore, QtGui import sip # Always succeeds *after* importing PyQt4.