ModuleNotFoundError: No module named 'pandas'
In most cases this error in Python generally raised:
- You haven't installed Pandas explicitly with pip install pandas.
- You may have different Python versions on your computer and Pandas is not installed for the particular version you're using.
Install pandas using pip
You can run the following command in your Linux/MacOS/Windows terminal.
pip install pandas
For Python 3:
pip3 install pandas
Upgrade version of Pandas
If you have already installed pandas , updating pandas would be the best solution for most cases.
pip3 install pandas --upgrade
Install specific version of pandas
If you want to install specific version of pandas:
pip3 install pandas==1.2.1
Install the same Python and Pandas version
To be sure you are not having multiple Python versions that are confusing, you should run following commands:
python3 -m pip install pandas
python3 -c 'import pandas'
Above command installs pandas and imports it with the same python version.
How to find the installed pandas version
After installing, you can check pandas version :
import pandas as pd
pd.__version__
If you run into issues with privileges , you may need to run:
sudo pip3 install pandas
#sudo pip3 install - installs as the root user.
sudo installs the package globally in your python installation, i.e. for all users.
Install PIP
PIP is a package management system used to install and manage libraries/packages written in Python. Python 3.4 and Python 2.7.9 included with Pip. If you do find that pip is not available when using Python Python 3.4+ or Python 2.7.9+ , simply execute :
py -3 -m ensurepip
If you don't have pip installed in older version of Python:
Download get-pip.py , being careful to save it as a .py file rather than .txt. Then, run it from the command prompt:
python get-pip.py
How to know the version of pip itself?
pip -V
Related Topics
- What is SettingWithCopyWarning?
- UnicodeDecodeError while reading CSV file
- How to fix CParserError: Error tokenizing data
- ValueError: cannot reindex from a duplicate axis
- How to fix "Unnamed: 0" column in a pandas DataFrame
- ValueError: cannot convert float NaN to integer
- ValueError: Unknown label type: 'unknown'
- ValueError: Length of values does not match length of index
- ValueError: The truth value of an array with more than..