From eda665208145d14c8eb506d248716e8063af2689 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 21 May 2026 11:29:36 +0200 Subject: [PATCH] Log import failure tracebacks during backend autodetection fallback. This should help troubleshooting backend autodetection issues. --- lib/matplotlib/pyplot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 57f5ac08e398..9c3f7e698cde 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -428,7 +428,9 @@ def switch_backend(newbackend: str) -> None: for candidate in candidates: try: switch_backend(candidate) - except ImportError: + except ImportError as exc: + _log.debug("Skipping backend candidate %r as loading failed.", + candidate, exc_info=True) continue else: rcParamsOrig['backend'] = candidate