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

4

5

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'
Baillargeon answered 24/3, 2019 at 12:54 Comment(0)
T
7

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.

Threedecker answered 24/3, 2019 at 14:44 Comment(2)
Thanks. This did work but only after I uninstalled and reinstalled later version of Anaconda.Baillargeon
Glad it worked. Just a sidenote that you can uninstall Anaconda by following the OS-specific instructions here. Third-party apps are fine in principle, but a lot of them contain malware or spyware, and they sometimes leave behind traces of the program.Threedecker
B
0

The problem was with conda command not being set up during the installation of Anaconda. I solved this by removing Anaconda with App Cleaner & Uninstaller Pro (free soft) and reinstalling later version.

After reinstallation of Anaconda command below worked like a charm.

conda install -c anaconda pandas-datareader 
Baillargeon answered 13/4, 2019 at 8:53 Comment(0)
B
0

If you using Anaconda and still have issues installing panads-datareader using the conda command 'conda install -c anaconda pandas-datareader'. or the installation is successful but the import pandas_datareader.data as web still gives an error.

Locate where your 'site-packages % ' directory and cd to the site-packages % dir and then run the installation command 'conda install -c anaconda pandas-datareader '. It will work.

Bonze answered 25/9, 2021 at 5:36 Comment(0)
U
0

First uninstall datareader using below command:

pip uninstall pandas_datareader

Then install using command:

conda install pandas-datareader

This is what worked for me!!

Ulphiah answered 17/7, 2023 at 9:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.