Search code examples
python-3.xpandasinstallationanacondapandas-datareader

No module named 'pandas_datareader' in Jupyter (Anaconda) after I run pip3 install pandas_datareader


I am trying to learn pandas and want to load some stocks data. I was following a course which advised me to load pandas.io.data, but this did not work as io.data was depreciated. So I decided to use pandas-datareader instead. But I am struggling to instal it on mac in Anaconda (Jupiter notebook).

First time I run import pandas_datareader as pdweb I got ModuleNotFoundError: No module named 'pandas_datareader'. Not surprising as I never used this before so I run pip3 install pandas_datareader in Terminal which successfully installed itself. However, Jupiter notebook is still giving me the same error. At this point, I tried running in Terminal conda install -c https://conda.anaconda.org/anaconda pandas-datareader but it did not work as -bash: conda: command not found.

Please help. I am looking for a detailed explanation as I am not too techie.

What I run in Jupiter

import numpy as np
from pandas import Series, DataFrame
import pandas as pd
import pandas_datareader as pdweb 
import datetime

Result

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-6-da568f513c93> in <module>
      2 from pandas import Series, DataFrame
      3 import pandas as pd
----> 4 import pandas_datareader as pdweb
      5 import datetime

ModuleNotFoundError: No module named 'pandas_datareader'

Solution

  • Just run

    conda install -c anaconda pandas-datareader 
    

    as per instructions here.

    In my experience, if you're using conda, you should never install with pip unless you're sure conda doesn't have it. Try searching anaconda.org to see which -c source to use.