Pandas ImportError:绘图需要matplotlib
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52701688/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Pandas ImportError: matplotlib is required for plotting
提问by Nishat21
Pandas does not recognize installed matplotlib library
Pandas 无法识别已安装的 matplotlib 库
here is the code
这是代码
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
ts.plot()
error is
错误是
c:\users\xxxxx\appdata\local\programs\python\python36\lib\site-packages\pandas\plotting\_core.py in _raise_if_no_mpl()
55 # TODO(mpl_converter): remove once converter is explicit
56 if not _HAS_MPL:
---> 57 raise ImportError("matplotlib is required for plotting.")
58
59
ImportError: matplotlib is required for plotting.
采纳答案by Nishat21
Installing matplotlib before installing pandas again made it work.
在再次安装 Pandas 之前安装 matplotlib 使其工作。
回答by Billy Jhon
All you had to do is quit Pandas after installing matplotlib and start it again. This way it would see fresh installation. No need to reinstall Pandas.
您所要做的就是在安装 matplotlib 后退出 Pandas 并重新启动它。这样它就会看到全新的安装。无需重新安装 Pandas。
回答by themefield
I got the same error in Jupyter Lab. The solution is (after install of matplotlib):
我在 Jupyter Lab 中遇到了同样的错误。解决方案是(安装 matplotlib 后):
Click Restart the Kernel
button in the toolbar;
点击Restart the Kernel
工具栏中的按钮;
or
或者
Choose menu item Kernel
=>Restart Kernel and Run All Cells...
, and click Restart
in the confirmation dialog
选择菜单项Kernel
=> Restart Kernel and Run All Cells...
,然后Restart
在确认对话框中单击
Done!
完成!
回答by Steffi Keran Rani J
You need to install matplotlib
for that.
您需要为此安装matplotlib
。
You can type and run the following command in your python shell to install matplotlib
您可以在 python shell 中键入并运行以下命令来安装 matplotlib
python3 -mpip install matplotlib
If you are using Anaconda IDE, you can run the following command in the Conda command prompt
如果您使用的是 Anaconda IDE,则可以在 Conda 命令提示符下运行以下命令
conda install matplotlib
Once installed, re-run the program.
安装后,重新运行程序。
Refer thispage for installing matplotlib.
请参阅此页面以安装 matplotlib。