如何解决ModuleNotFoundError: No module named 'pandas_datareader'错误?
ModuleNotFoundError: No module named 'pandas_datareader' Hey there, that error happens because pandas_datareader isn’t part of Python’s standard library, nor does it come bundled with pandas by default—it’s a separate package you need to install first. Let’s get this sorted quickly so you can get back to your tutorial:
1. Install using pip (most common approach)
Open your terminal or command prompt and run one of these commands, depending on your setup:
- If
pipis linked to your Python 3 environment (or you’re using Python 2):pip install pandas-datareader - If you have multiple Python versions and need to target Python 3 explicitly:
pip3 install pandas-datareader - Pro tip: If you’re using a virtual environment (highly recommended for project isolation), make sure it’s activated before running the command.
2. Install using conda (for Anaconda/Miniconda users)
If you manage your Python environment with Anaconda, run this command in your terminal:
conda install -c anaconda pandas-datareader
Verify the installation
Once the install finishes, test it to make sure it worked. Open a Python shell or your IDE and run:
import pandas_datareader
If you don’t get any error messages, you’re all set to jump back to the 7:14 mark in your tutorial!
Quick note on permission issues
If you hit a permission error (common on macOS/Linux), avoid using sudo (it can mess up your system-wide Python setup). Instead, either use a virtual environment, or add the --user flag to install the package only for your user account:
pip install --user pandas-datareader
内容的提问来源于stack exchange,提问作者Oscar Bomboscar

