For some reason, I can't even run this basic line. It should just accept this, but it won't even do that. Every time I open Jupyter Notebook, something like this has to happen. And of course, there isn't really any way to permanently fix it. There hasn't been much that I can try, but messing around with Jupyter has also screwed up my other IDEs.
from __future__ import print_function, division
%matplotlib inline
import numpy as np
import nsfg
import first
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-58d7125e1e68> in <module>
1 from __future__ import print_function, division
2
----> 3 get_ipython().run_line_magic('matplotlib', 'inline')
4
5 import numpy as np
~/opt/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2315 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2316 with self.builtin_trap:
-> 2317 result = fn(*args, **kwargs)
2318 return result
2319
</Users/hedyeherfani/opt/anaconda3/lib/python3.7/site-packages/decorator.py:decorator-gen-108> in matplotlib(self, line)
~/opt/anaconda3/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):
~/opt/anaconda3/lib/python3.7/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
~/opt/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
3417 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
3418
-> 3419 pt.activate_matplotlib(backend)
3420 pt.configure_inline_support(self, backend)
3421
~/opt/anaconda3/lib/python3.7/site-packages/IPython/core/pylabtools.py in activate_matplotlib(backend)
318 # when this function runs.
319 # So avoid needing matplotlib attribute-lookup to access pyplot.
--> 320 from matplotlib import pyplot as plt
321
322 plt.switch_backend(backend)
~/opt/anaconda3/lib/python3.7/site-packages/matplotlib/pyplot.py in <module>
30 from cycler import cycler
31 import matplotlib
---> 32 import matplotlib.colorbar
33 import matplotlib.image
34 from matplotlib import rcsetup, style
~/opt/anaconda3/lib/python3.7/site-packages/matplotlib/colorbar.py in <module>
25
26 import matplotlib as mpl
---> 27 import matplotlib.artist as martist
28 import matplotlib.cbook as cbook
29 import matplotlib.collections as collections
~/opt/anaconda3/lib/python3.7/site-packages/matplotlib/artist.py in <module>
12 from . import cbook, docstring, rcParams
13 from .path import Path
---> 14 from .transforms import (Bbox, IdentityTransform, Transform, TransformedBbox,
15 TransformedPatchPath, TransformedPath)
16
ImportError: cannot import name 'Bbox' from 'matplotlib.transforms' (/Users/hedyeherfani/opt/anaconda3/lib/python3.7/site-packages/matplotlib/transforms.py)
Looks like you're using a very old version of matplotlib. For example, version 0.91.2 doesn't have class Bbox in transforms.py, but most newer versions do.
To confirm this, open the referenced file, /Users/hedyeherfani/opt/anaconda3/lib/python3.7/site-packages/matplotlib/transforms.py, and check for class Bbox(BboxBase)
or something similar (a symbol called Bbox needs to be defined)
Evaluate import matplotlib; matplotlib.__version__
import matplotlib; matplotlib.__version__
into a Python interpreter to determine your version of matplotlib.
Upgrade by using a command such as pip install matplotlib==<newversion> --upgrade
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.