我正在使用jupyter和python2。当我尝试使用此命令时
          from matplotlib import pyplot as plt

在jupyter笔记本中,它会出现此错误

     ImportError                               Traceback (most recent      call last)
<ipython-input-4-99ba79ecbbfb> in <module>()
----> 1 from matplotlib import pyplot as plt

/home/adarsh/.local/lib/python2.7/site-packages/matplotlib/__init__.py in <module>()
    124 # cbook must import matplotlib only within function
    125 # definitions, so it is safe to import from it here.
--> 126 from . import cbook
    127 from matplotlib.cbook import (
    128     _backports, mplDeprecation, dedent, get_label, sanitize_sequence)

ImportError: cannot import name cbook


我用Ubuntu

知道如何解决吗?

最佳答案

尝试更新matplotlib

python -m pip install -U matplotlib


如果这不起作用,请尝试卸载并重新安装它

python -m pip uninstall matplotlib


然后

python -m pip install -U matplotlib


让我知道是否可以解决此问题。

关于python - Jupyter ImportError:无法导入名称cbook,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52242964/

10-16 01:19