How do I know if Python has pandas installed?


To check whether the pandas package is installed or not in python we can simply verify the version. To get the version details of pandas we have two options.

The first one is using the __version__ attribute.

Example

import pandas as pd
print(pd.__version__)

Explanation

To verify the version number of pandas, we can use this __version__ built-in attribute provided by pandas, this will return you the number specifying which version of pandas we have.

Output

1.1.5

The number 1.1.5 represents the version of pandas that is already available.

The second way is using the pandas show_versions() method.

Example

print(pd.show_versions())

show_versions() is a pandas method that will not only give you the information about pandas version, it also provides the details about versions of python and pandas dependent packages and OS Type.

Output

INSTALLED VERSIONS
------------------
commit            : b5958ee1999e9aead1938c0bba2b674378807b3d
python            : 3.8.3.final.0
python-bits       : 32
OS                : Windows
OS-release        : 10 
Version           : 10.0.19041
machine           : AMD64
processor         : Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder         : little
LC_ALL            : None
LANG              : None
LOCALE            : English_United States.1252

pandas            : 1.1.5
NumPy             : 1.19.4
pytz              : 2020.1
dateutil          : 2.8.1
pip               : 20.3.3
setuptools        : 41.2.0
Cython            : None
pytest            : None
hypothesis        : None
sphinx            : None
blosc             : None
feather           : None
xlsxwriter        : None
lxml.etree        : None
html5lib          : None
pymysql           : None
psycopg2          : None
jinja2            : 2.11.2
IPython           : 7.19.0
pandas_datareader : None
bs4               : None
bottleneck        : None
fsspec            : None
fastparquet       : None
gcsfs             : None
matplotlib        : 3.3.3
numexpr           : None
odfpy             : None
openpyxl          : None
pandas_gbq        : None
pyarrow           : None
pytables          : None
pyxlsb            : None
s3fs              : None
scipy             : 1.5.4
sqlalchemy        : None
tables            : None
tabulate          : None
xarray            : None
xlrd              : None
xlwt              : None
numba             : None

The above block represents the version of all pandas dependents and python.

You will find an error message if we don’t have the pandas package. The error message will be like this.

ModuleNotFoundError

The above error will rise when python cannot successfully import a module. In our situation, there may be a chance that we have not yet installed the pandas package or it may be a spelling mistake.

If you found this above error, then install the pandas package. These are the two ways to identify if pandas installed or not.

Updated on: 17-Nov-2021

14K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements