我正在研究 jupyter 和 python 2。当我尝试使用这个命令时 从 matplotlib 将 pyplot 导入为 plt
在 jupyter notebook 中它解决了这个错误
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
如果这解决了问题,请告诉我。
