diff --git a/external-deps/spyder-kernels/.gitrepo b/external-deps/spyder-kernels/.gitrepo index f726b52bc9f..67bef785e7c 100644 --- a/external-deps/spyder-kernels/.gitrepo +++ b/external-deps/spyder-kernels/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/spyder-ide/spyder-kernels.git branch = master - commit = 705618596160a1d65a7a0fc71cec1cfc41fbcaeb - parent = 3852ec47717cd061a2b9719501a5b5e1f9571f18 + commit = f9fc2f62179a98cf582b44306a9f9225506ec532 + parent = 3d037175c3ae4bb20f1366a6e5446ae064ed6306 method = merge cmdver = 0.4.9 diff --git a/external-deps/spyder-kernels/spyder_kernels/console/shell.py b/external-deps/spyder-kernels/spyder_kernels/console/shell.py index d2d32a85f11..3e9224c9df6 100644 --- a/external-deps/spyder-kernels/spyder_kernels/console/shell.py +++ b/external-deps/spyder-kernels/spyder_kernels/console/shell.py @@ -101,6 +101,33 @@ def enable_matplotlib(self, gui=None): enabled_gui = "inline" gui = enabled_gui + # Check if the inline backend is registered. It should be at this + # point, but sometimes that can fail due to a mismatch between + # the installed versions of IPython, matplotlib and matplotlib-inline. + # Fixes spyder-ide/spyder#22420. + if gui == "inline": + is_inline_registered = False + + # The flush_figures callback should be listed as a post_execute + # event if the backend was registered successfully. + for event in self.events.callbacks["post_execute"]: + if "matplotlib_inline.backend_inline.flush_figures" in repr( + event + ): + is_inline_registered = True + break + + # Manually register the backend in case it wasn't + if not is_inline_registered: + from IPython.core.pylabtools import activate_matplotlib + from matplotlib_inline.backend_inline import ( + configure_inline_support + ) + + backend = "module://matplotlib_inline.backend_inline" + activate_matplotlib(backend) + configure_inline_support(self, backend) + # To easily track the current interactive backend if self.kernel.interactive_backend is None: self.kernel.interactive_backend = gui if gui != "inline" else None