I'm trying to use 'Qt5Agg' matplotlib backend in Jupyter , but when I run %matplotlib qt
, i get the following error:
(我正在尝试在Jupyter中使用'Qt5Agg'matplotlib后端,但是当我运行%matplotlib qt
,出现以下错误:)
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-092debfcf002> in <module>
----> 1 get_ipython().run_line_magic('matplotlib', 'tk')
2 import numpy as np
3 from scipy.integrate import odeint
4 import matplotlib.pyplot as plt
5
~/.local/lib/python3.5/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2312 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2313 with self.builtin_trap:
-> 2314 result = fn(*args, **kwargs)
2315 return result
2316
</home/cs/.local/lib/python3.5/site-packages/decorator.py:decorator-gen-108> in matplotlib(self, line)
~/.local/lib/python3.5/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
~/.local/lib/python3.5/site-packages/IPython/core/magics/pylab.py in 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)
101
~/.local/lib/python3.5/site-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
3412 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
3413
-> 3414 pt.activate_matplotlib(backend)
3415 pt.configure_inline_support(self, backend)
3416
~/.local/lib/python3.5/site-packages/IPython/core/pylabtools.py in activate_matplotlib(backend)
312
313 import matplotlib.pyplot
--> 314 matplotlib.pyplot.switch_backend(backend)
315
316 # This must be imported last in the matplotlib series, after
~/.local/lib/python3.5/site-packages/matplotlib/pyplot.py in switch_backend(newbackend)
220 "Cannot load backend {!r} which requires the {!r} interactive "
221 "framework, as {!r} is currently running".format(
--> 222 newbackend, required_framework, current_framework))
223
224 rcParams['backend'] = rcParamsDefault['backend'] = newbackend
ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'headless' is currently running
I tried running first:
(我尝试先运行:)
import matplotlib
matplotlib.use('Qt5Agg')
but if i run again %matplotlib qt
, i'm getting the same error.
(但是,如果我再次运行%matplotlib qt
,我将得到相同的错误。)
If i don't run the magic command, and i plot something, it doesn't show anything. (如果我没有运行magic命令,并且绘制了一些东西,那么它什么也不会显示。)
ask by CS10 translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…