matplotlib / ipympl

Matplotlib Jupyter Integration
https://matplotlib.org/ipympl/
BSD 3-Clause "New" or "Revised" License
1.57k stars 227 forks source link

No event loop integration for 'widget' #451

Closed justinTM closed 2 years ago

justinTM commented 2 years ago

Describe the issue

Python 3.10 macOS 10.15 ipython 8.2.0

In [17]: %matplotlib widget
---------------------------------------------------------------------------
UnknownBackend                            Traceback (most recent call last)
Input In [17], in <cell line: 1>()
----> 1 get_ipython().run_line_magic('matplotlib', 'widget')

File /usr/local/lib/python3.10/site-packages/IPython/core/interactiveshell.py:2294, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth)
   2292     kwargs['local_ns'] = self.get_local_scope(stack_depth)
   2293 with self.builtin_trap:
-> 2294     result = fn(*args, **kwargs)
   2295 return result

File /usr/local/lib/python3.10/site-packages/IPython/core/magics/pylab.py:99, in PylabMagics.matplotlib(self, line)
     97     print("Available matplotlib backends: %s" % backends_list)
     98 else:
---> 99     gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui)
    100     self._show_matplotlib_backend(args.gui, backend)

File /usr/local/lib/python3.10/site-packages/IPython/core/interactiveshell.py:3464, in InteractiveShell.enable_matplotlib(self, gui)
   3460 configure_inline_support(self, backend)
   3462 # Now we must activate the gui pylab wants to use, and fix %run to take
   3463 # plot updates into account
-> 3464 self.enable_gui(gui)
   3465 self.magics_manager.registry['ExecutionMagics'].default_runner = \
   3466     pt.mpl_runner(self.safe_execfile)
   3468 return gui, backend

File /usr/local/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py:711, in TerminalInteractiveShell.enable_gui(self, gui)
    708 def enable_gui(self, gui=None):
    709     if gui and (gui != 'inline') :
    710         self.active_eventloop, self._inputhook =\
--> 711             get_inputhook_name_and_func(gui)
    712     else:
    713         self.active_eventloop = self._inputhook = None

File /usr/local/lib/python3.10/site-packages/IPython/terminal/pt_inputhooks/__init__.py:48, in get_inputhook_name_and_func(gui)
     45     return gui, registered[gui]
     47 if gui not in backends:
---> 48     raise UnknownBackend(gui)
     50 if gui in aliases:
     51     return get_inputhook_name_and_func(aliases[gui])

UnknownBackend: No event loop integration for 'widget'. Supported event loops are: qt, qt4, qt5, qt6, gtk, gtk2, gtk3, gtk4, tk, wx, pyglet, glut, osx, asyncio
ianhi commented 2 years ago

Are you running this in IPYthon in the terminal or a notebook context? ipympl only will work in a notbeook context (e.g. jupyter lab, jupyter notbeook, colab etc)

justinTM commented 2 years ago

Ah gotcha, yeah it was in a terminal.