From 75ac1bdaab50c617a151b7a1d76450a4b05b596f Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 3 Jun 2024 12:14:13 -0400 Subject: [PATCH] Backport PR #28332: Call IPython.enable_gui when install repl displayhook --- lib/matplotlib/pyplot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index a3ce60f01ef5..1a8298212709 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -304,10 +304,12 @@ def install_repl_displayhook() -> None: # This code can be removed when Python 3.12, the latest version supported by # IPython < 8.24, reaches end-of-life in late 2028. from IPython.core.pylabtools import backend2gui - # trigger IPython's eventloop integration, if available ipython_gui_name = backend2gui.get(get_backend()) - if ipython_gui_name: - ip.enable_gui(ipython_gui_name) + else: + _, ipython_gui_name = backend_registry.resolve_backend(get_backend()) + # trigger IPython's eventloop integration, if available + if ipython_gui_name: + ip.enable_gui(ipython_gui_name) def uninstall_repl_displayhook() -> None: