How to Fix: No module named pandas
Last Updated :
16 Jun, 2025
When working with Python, you may encounter the error ModuleNotFoundError: No module named 'pandas'. This error occurs when you try to import the pandas library without having it installed in your Python environment. Since pandas is not included with the standard Python installation, it must be installed manually. Example:
Python
import pandas
pandas.DataFrame({'a': [1, 2]})
If pandas isn't installed, you'll see:
ModuleNotFoundError: No module named 'pandas'
Let's understand different method to solve this error.
1. Install Pandas Using pip
The easiest way to install pandas is through Python’s built-in package manager pip. Just open your terminal or command prompt and type:
pip install pandas
This will download and install the library. You’ll see an output like this:
Collecting pandas
Downloading pandas-3.2.0.tar.gz (281.3 MB)
...
Successfully installed pandas-3.2.0
2. Verify the Installation
Once installed, you can verify it by importing and checking the version:
Python
import pandas as pd
print(pd.__version__)
Output
1.3.4
Explanation: This will show you the version of pandas installed.
3. Show Module details
You can get more details about the installed pandas package using this command:
pip show pandas
Output
Name: pandas
Version: 1.3.4
Summary: Powerful data structures for data analysis
Location: /usr/local/lib/python3.x/site-packages
Requires: numpy, python-dateutil, pytz
Explanation: This can help confirm where pandas is installed and what dependencies it needs.
4. Upgrade Pandas
If your pandas version is outdated or you want the latest features and bug fixes, upgrade it using:
pip install --upgrade pandas
This ensures you have the latest features and security fixes.
5. Install a Specific Version
Need a specific version of pandas for compatibility with a project.
pip install pandas==1.3.4
This installs version 1.3.4 of pandas.
6. Using pip3 or python3
On some systems especially Linux/macOS, you may need to use pip3 instead of pip:
pip3 install pandas
Or run Python using:
python3 your_script.py
This ensures you’re installing and running pandas with the correct version of Python.