Closed dzanaga closed 1 year ago
This setup always worked previously when I was working on python 3.7, here I switched to 3.9. not sure what's going on.
Everything looks fine on your setup. Could you try an hard refresh of your web page (ctrl + shift + R
) to make sure you're not hitting some browser cache?
I tried, but no luck
Another detail, not sure it's related, but when I run for the first time %matplotlib ipympl
it works, if I re-run it a second time it throws an error:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[3], line 4
2 get_ipython().run_line_magic('reload_ext', 'autoreload')
3 get_ipython().run_line_magic('autoreload', '2')
----> 4 get_ipython().run_line_magic('matplotlib', 'ipympl')
File ~/miniconda3/envs/eo42/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2364, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth)
2362 kwargs['local_ns'] = self.get_local_scope(stack_depth)
2363 with self.builtin_trap:
-> 2364 result = fn(*args, **kwargs)
2365 return result
File ~/miniconda3/envs/eo42/lib/python3.9/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 ~/miniconda3/envs/eo42/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3528, in InteractiveShell.enable_matplotlib(self, gui)
3524 print('Warning: Cannot change to a different GUI toolkit: %s.'
3525 ' Using %s instead.' % (gui, self.pylab_gui_select))
3526 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
-> 3528 pt.activate_matplotlib(backend)
3529 configure_inline_support(self, backend)
3531 # Now we must activate the gui pylab wants to use, and fix %run to take
3532 # plot updates into account
File ~/miniconda3/envs/eo42/lib/python3.9/site-packages/IPython/core/pylabtools.py:360, in activate_matplotlib(backend)
355 # Due to circular imports, pyplot may be only partially initialised
356 # when this function runs.
357 # So avoid needing matplotlib attribute-lookup to access pyplot.
358 from matplotlib import pyplot as plt
--> 360 plt.switch_backend(backend)
362 plt.show._needmain = False
363 # We need to detect at runtime whether show() is called by the user.
364 # For this, we wrap it into a decorator which adds a 'called' flag.
File ~/miniconda3/envs/eo42/lib/python3.9/site-packages/matplotlib/pyplot.py:227, in switch_backend(newbackend)
225 # make sure the init is pulled up so we can assign to it later
226 import matplotlib.backends
--> 227 close("all")
229 if newbackend is rcsetup._auto_backend_sentinel:
230 current_framework = cbook._get_running_interactive_framework()
File ~/miniconda3/envs/eo42/lib/python3.9/site-packages/matplotlib/pyplot.py:912, in close(fig)
910 _pylab_helpers.Gcf.destroy(manager)
911 elif fig == 'all':
--> 912 _pylab_helpers.Gcf.destroy_all()
913 elif isinstance(fig, int):
914 _pylab_helpers.Gcf.destroy(fig)
File ~/miniconda3/envs/eo42/lib/python3.9/site-packages/matplotlib/_pylab_helpers.py:82, in Gcf.destroy_all(cls)
80 for manager in list(cls.figs.values()):
81 manager.canvas.mpl_disconnect(manager._cidgcf)
---> 82 manager.destroy()
83 cls.figs.clear()
File ~/miniconda3/envs/eo42/lib/python3.9/site-packages/ipympl/backend_nbagg.py:471, in FigureManager.destroy(self)
470 def destroy(self):
--> 471 self.canvas.close()
File ~/miniconda3/envs/eo42/lib/python3.9/site-packages/ipywidgets/widgets/widget.py:500, in Widget.close(self)
498 if self.comm is not None:
499 Widget._active_widgets.pop(self.model_id, None)
--> 500 self.comm.close()
501 self.comm = None
502 self._repr_mimebundle_ = None
File ~/miniconda3/envs/eo42/lib/python3.9/site-packages/comm/base_comm.py:109, in BaseComm.close(self, data, metadata, buffers, deleting)
101 self.publish_msg(
102 "comm_close",
103 data=data,
104 metadata=metadata,
105 buffers=buffers,
106 )
107 if not deleting:
108 # If deleting, the comm can't be registered
--> 109 comm.get_comm_manager().unregister_comm(self)
File ~/miniconda3/envs/eo42/lib/python3.9/site-packages/comm/base_comm.py:199, in CommManager.unregister_comm(self, comm)
197 """Unregister a comm, and close its counterpart"""
198 # unlike get_comm, this should raise a KeyError
--> 199 comm = self.comms.pop(comm.comm_id)
KeyError: '193ed29e4cc442dfbafc849398cd3615'
😞 Please try to downgrade ipykernel to 6.17.1
...
yep, that fixed it, thanks for figuring it out!
Describe the issue
I have a fresh miniconda installation. On the
base
environment I have installedjupyter
andipympl
. Plotting when using thebase
kernel works as expected. The problem occurs when I am switching to another kernel. I created a new conda env where I installedmatplotlib, ipympl, ipykernel
, added the kernel tojupyter
. When plotting while using this new kernel, the figure does not render.In the base env:
In the other kernel:
Versions
base env:
second env: