Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas ImportError: matplotlib is required for plotting

Pandas does not recognize installed matplotlib library

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.
like image 210
Nishat21 Avatar asked Oct 08 '18 11:10

Nishat21


Video Answer


2 Answers

Installing matplotlib before installing pandas again made it work.

like image 200
Nishat21 Avatar answered Sep 25 '22 03:09

Nishat21


I got the same error in Jupyter Lab. The solution is (after install of matplotlib):

Click Restart the Kernel button in the toolbar;

or

Choose menu item Kernel=>Restart Kernel and Run All Cells..., and click Restart in the confirmation dialog

Done!

like image 21
themefield Avatar answered Sep 23 '22 03:09

themefield