@@ -202,9 +202,12 @@ def install_repl_displayhook():
202
202
203
203
from IPython .core .pylabtools import backend2gui # type: ignore
204
204
# trigger IPython's eventloop integration, if available
205
- ipython_gui_name = backend2gui .get (get_backend ())
206
- if ipython_gui_name :
207
- ip .enable_gui (ipython_gui_name )
205
+ try :
206
+ ipython_gui_name = backend2gui .get (get_backend ())
207
+ if ipython_gui_name :
208
+ ip .enable_gui (ipython_gui_name )
209
+ except NotImplementedError as err :
210
+ raise ImportError ('Fallback to a different backend.' ) from err
208
211
209
212
210
213
def uninstall_repl_displayhook ():
@@ -389,7 +392,6 @@ def draw_if_interactive():
389
392
for func_name in ["new_figure_manager" , "draw_if_interactive" , "show" ]:
390
393
globals ()[func_name ].__signature__ = inspect .signature (
391
394
getattr (backend_mod , func_name ))
392
-
393
395
# Need to keep a global reference to the backend for compatibility reasons.
394
396
# See https://github.com/matplotlib/matplotlib/issues/6092
395
397
matplotlib .backends .backend = newbackend
@@ -398,7 +400,11 @@ def draw_if_interactive():
398
400
399
401
# make sure the repl display hook is installed in case we become
400
402
# interactive
401
- install_repl_displayhook ()
403
+ try :
404
+ install_repl_displayhook ()
405
+ except ImportError as err :
406
+ _log .warning (str (err ))
407
+ raise ImportError
402
408
403
409
404
410
def _warn_if_gui_out_of_main_thread ():
0 commit comments