[英]Jupyter notebook `pylab inline` gives `matplotlib` error
Previously, I was working on a Jupyter notebook project on a mac running Python 3.7. 以前,我在运行Python 3.7的Mac上从事Jupyter笔记本项目的研究。
Today, when I wanted to load the notebook's %pylab inline
machinery, I received the error: 今天,当我想加载笔记本的%pylab inline
机器时,我收到了以下错误消息:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-a6e0d37a4680> in <module>
----> 1 get_ipython().run_line_magic('pylab', 'inline')
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2283 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2284 with self.builtin_trap:
-> 2285 result = fn(*args,**kwargs)
2286 return result
2287
<decorator-gen-108> in pylab(self, line)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/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):
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site- packages/IPython/core/magics/pylab.py in pylab(self, line)
153 import_all = not args.no_import_all
154
--> 155 gui, backend, clobbered = self.shell.enable_pylab(args.gui, import_all=import_all)
156 self._show_matplotlib_backend(args.gui, backend)
157 print ("Populating the interactive namespace from numpy and matplotlib")
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/IPython/core/interactiveshell.py in enable_pylab(self, gui, import_all, welcome_message)
3390 from IPython.core.pylabtools import import_pylab
3391
-> 3392 gui, backend = self.enable_matplotlib(gui)
3393
3394 # We want to prevent the loading of pylab to pollute the user's
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
3339 """
3340 from IPython.core import pylabtools as pt
-> 3341 gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select)
3342
3343 if gui != 'inline':
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/IPython/core/pylabtools.py in find_gui_and_backend(gui, gui_select)
274 """
275
--> 276 import matplotlib
277
278 if gui and gui != 'auto':
ModuleNotFoundError: No module named 'matplotlib'
I've tried looking for solutions online. 我尝试过在线寻找解决方案。
I have removed Python 3.6, reinstalled brew from scratch, reinstalled jupyter from scratch using the terminal but to no solution. 我删除了Python 3.6,从头开始重新安装brew,使用终端从头开始重新安装jupyter,但没有解决方案。
Is there a solution? 有解决方案吗?
Don't use %pylab
, it is deprecated. 不要使用%pylab
,它已被弃用。 Use either: 使用以下任一方法:
%matplotlib inline
or %matplotlib notebook
或%matplotlib notebook
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.