26

I have just installed pandas_datareader using pip install pandas-datareader which ran successfully.

Now I am trying to use it for a tutorial and I am getting this error when I try to import.

    import pandas_datareader as pdr

ModuleNotFoundError: No module named 'pandas_datareader'

This is the link to the tutorial.

https://www.datacamp.com/community/tutorials/finance-python-trading#gs.DgsO1BY

Any ideas?

helcode
  • 1,859
  • 1
  • 13
  • 32
Goulouh Anwar
  • 737
  • 1
  • 11
  • 21
  • 1
    You probably just installed the package for the wrong version of python. Make sure you are using the right `pip`. Usually the safest thing to do is to run: `sudo python3 -m pip install pandas_datareader` if you are trying to install the package for your python3 installation. – Abdou Sep 17 '17 at 22:29
  • sorry using windows cmd so???? python3 -m pip install pandas_datareader??? can i use -upgrade to upgrade to 3x vers? – Goulouh Anwar Sep 18 '17 at 02:42
  • I wrongly assumed that you were on some form of `unix` machine (mac, ubuntu or what not). But you should be able to use the same command, except for the `sudo` prefix: `python3 -m pip install pandas_datareader`. You can use `--upgrade` to make sure you are getting the latest version of the package. Please don't assume that `--upgrade` is for upgrading python's version. It's mainly to make sure you are installing the latest version of the package. – Abdou Sep 18 '17 at 03:23
  • my apologies for missing out the win info i tried that exact command 'python3 -m pip install pandas_datareader' and had a python not a recognised command error – Goulouh Anwar Sep 18 '17 at 06:15
  • this is bey0nd frustrating you would think 1: the tutorial would trole shoot this stuff for you without sending you to thirdparty website where you have to troll through Jupyter Entries to find a solution and more importantly 2:When using pip install pandas_datareaders it should just install the latest version for you and match to your version of python also . If you can build a complicated module at least put some effort into making it easy to install!! – Goulouh Anwar Sep 18 '17 at 06:18
  • C:\WINDOWS\system32>python3 -m pip install pandas_datareader 'python3' is not recognized as an internal or external command, operable program or batch file. – Goulouh Anwar Sep 18 '17 at 06:19
  • You need to find your python3 installation. I don't think anybody will do that for you. Also, if you choose to install a package, you should be comfortable with the idea that it is your responsibility to figure out how to install it. The fact that someone wrote an entire library and shared it with you is a true act of kindness. – Abdou Sep 18 '17 at 14:20
  • That said, open `spyder` and run `import sys; sys.executable`. This should tell you where your python installation is. You can then use that path to call pip. Instead of `python3 -m pip install pandas_datareade`, you can replace `python3` with the output of `sys.executable`. – Abdou Sep 18 '17 at 14:22
  • 2
    I was getting the same error. The following command worked for me: `pip3 install pandas_datareader` – Abhishek Upadhyaya Nov 13 '17 at 23:05
  • After updating my miniconda, I got the same error. I tried `conda install`, not available. I tried `pip install`, already installed. After a reboot of the machine, it is now back to work. Hope this helps! – laviex Jan 02 '18 at 22:07
  • Guys, the command is right, the platform is wrong. For Python on Windows, the command is "python -m pip install pandas_datareader", not "python3..." or "pip3..." The suffix of "3" on python3 and pip3 is for Mac OS and Linux only. – Rich Lysakowski PhD Jul 12 '19 at 04:42

16 Answers16

39

Type into Terminal:

pip install pandas_datareader

That's it

Axis
  • 2,066
  • 2
  • 21
  • 40
  • 15
    you would think it was that easy and assuming i havent googled it first is a bit rude.... Im getting this. ) Requirement already satisfied: pandas>=0.17.0 in c:\program files (x86)\python36\lib\site-packages (from pandas_datareader) – Goulouh Anwar Sep 18 '17 at 02:34
  • 1
    Do you mean `pandas_datareader` or actually `pandas-datareader` (underscore versus dash in the package name)? – Marius Butuc Oct 28 '21 at 03:08
6

In your Anaconda Prompt, do this : pip install pandas_datareader

akshayk07
  • 2,092
  • 1
  • 20
  • 32
M_M
  • 899
  • 8
  • 21
6

Ok the following steps resolved the "No module named 'pandas_datareader" issue for me. To be clear, my situation was such that I had already installed pandas_datareader via pip install pandas_datareader but the "No module named 'pandas_datareader" error still kept popping up whenever I ran a .py code that imports pandas_datareader.

If you are in the same situation as I was (on Mac), this may help you.

Step 1: Uninstall the pandas_datareader package first:

  • via terminal, type pip uninstall pandas_datareader
  • it will prompt you asking for a y/n answer to proceed with the uninstallation
  • type 'y'

Step 2: Restart your IDE if you were using one

  • in my case, I was using MS VSC (Visual Studio Code)

Step 3:: re-install pandas_datareader package

  • again via terminal, type pip install pandas_datareader

  • your terminal may show you a bunch of "pre-installed" pandas_datareader package with message "Requirement already satisfied..."

  • ignore those.

Step 4: Run your python code again

  • the "No module named 'pandas_datareader" error should be gone this time round.

Hope this helps.

Jason Wong
  • 61
  • 1
  • 3
5

All the other methods didn't work for me.

In command prompt: conda install -c delichon pandas_datareader

This is working fine on 22nd sept 2019 make sure to update pip.

Hunting
  • 51
  • 1
  • 3
  • This command gives me an `PackagesNotFoundError`. However, the official one from the conda web works: `conda install -c anaconda pandas-datareader` – j.moustafa Mar 13 '20 at 19:44
5

For me, Import pandas_datareader worked from the command prompt while using python but did not work in jupyter.

From inside jupyter in a cell, I ran pip install pandas_datareader

I got a whole host of "Requirement already satisfied" messages

But at the very end, I was given this very important message. Successfully installed pandas-datareader-0.8.1 Note: you may need to restart the kernel to use updated packages In Jupyter notebook.

There is a kernel menu command sitting between cell and widgets. The restart command is in that drop-down menu option. In my case, this restarting of the kernel was the solution to my " No module named 'pandas_datareader' " all along.

Trevor Weir
  • 51
  • 1
  • 1
  • This worked for me too, but I had already tried restarting the kernel. The secret sauce was using the pip install in Jupyter Notebook, instead of at the cmd prompt. – Wei Jun 28 '21 at 14:02
3

Had the same issue. This resolved it for me:

after activating the env, run:

pip install pip --upgrade
pip install pandas-datareader
pip install jupyter (as i was using a jupyter notebook)

However, if you are running anaconda, use:

conda install -c anaconda pandas-datareader
DanielM
  • 3,598
  • 5
  • 37
  • 53
Quantum Prophet
  • 337
  • 2
  • 8
  • can you tell me what "conda install -c anaconda pandas-datareader"? – Aquiles Páez Mar 31 '21 at 15:43
  • About my previous commentary: ok, in the docs it shows that is for "Channel Customization". https://docs.conda.io/projects/conda/en/latest/commands/install.html#Channel%20Customization Does it mean I'm choosing "Anaconda" as source to download pandas-datareader? – Aquiles Páez Mar 31 '21 at 16:08
1

I had the same problem. I tried pip install pandas_datareader in my Anaconda Prompt and the problem was solved. For some reason, it didn't work in command prompt.

1

Got this error even though I had pandas_datareader installed. Running on Windows. py -3 -m pip install pandas_datareader in the command prompt didn't work. Same in anaconda prompt didn't work. pip uninstall pandas_datareader followed by pip install pandas_datareader and a reboot finally fixed my problem.

TLDR if running on a Windows machine, uninstall pandas_datareader if you have it (pip uninstall pandas_datareader) and then reinstall with 'pip install pandas_datareader'.

mate00
  • 2,727
  • 5
  • 26
  • 34
1

I had the same issue installing through my terminal. Since I'm using Anaconda Navigator, I tried the CMD.exe Prompt and inputted "conda install -c conda-forge pandas-datareader".

Jupyter notebook now works like a charm.

1

I was having this same issue in Jupyter Notebook, where it wasnt recognizing pandas_datareader, even though it said that it was installed successfully in anaconda prompt.

I figured out that my jupyter notebook wasnt opening up in my environment. I activated my environment in Anaconda Prompt and then did conda install nb_conda_kernels. When I opened up Jupyter notebook and checked my env, I was in the correct one, and it recognized my pandas_datareader import. You can check your environment using:

import sys
print(sys.prefix)

This is a SO thread that helped me: Conda environments not showing up in Jupyter Notebook

nwitte
  • 41
  • 2
0

You may consider upgrading your pandas with:

pip3 install --upgrade pandas
RocqJones
  • 273
  • 4
  • 9
0

I was having the same issue. I tried pip install pandas-datareader, pip install pandas_datareader, python3 -m pip install pandas_datareader on termianl, I see message saying I have successfully installed the package but none of them worked. I use Pycharm as my IDE and when I checked File-->Setting-->Progect:File-->Python interpreter, pandas-datareader is not in the package list. I use anaconda as my python Interpreter. So, just added the package into the interpreter and finally worked.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 28 '22 at 08:18
0

if you facing this error ,you have have to install pandas_datareader. you can install this package by Jupyter notebook also. "pip install pandas_datareader"

enter image description here

Bepasha
  • 1
  • 1
0

I was facing same problem which was solved when I ran this code on the conda terminal:

conda install pandas-datareader

I don't know why it was not working but this solved my problem.

MD Mushfirat Mohaimin
  • 1,966
  • 3
  • 10
  • 22
sagar
  • 1
  • 1
-1

Go to C:\Users\[UserName]\AppData\Roaming\jupyter\kernels\python3 and open up kernel.json. Check the first argument is pointing to a Python 3 environment/the environment you installed pandas_datareader to.

mcfroob
  • 1,044
  • 1
  • 11
  • 13
-1

If you are facing this issue in Jupyter Notebook, just restart the kernel within the IDE. -Make sure u have installed pandas_datareader with "pip install pandas_datareader" -Click on the tab named 'kernel' -Click Restart

Your Problem will be resolved

DhruvStan7
  • 149
  • 1
  • 6