How to Fix Importerror: Install XLRD for Excel Support in Python
-
Pandas
Package in Python -
Reasons for
importerror: install xlrd for excel support
-
Solution for
importerror: install xlrd for excel support
In today’s tutorial, we will explore the reasons and solutions for the following error we may get while working with the Pandas
package in Python.
ImportError: Install xlrd >= 0.9.0 for Excel support
Let’s start by going through a brief introduction of Pandas
.
Pandas
Package in Python
Pandas
is a popular tool specially built for Machine Learning and Data Science. It is primarily used for data analysis and cleaning.
It is an open-source Python package and one of the best tools for handling real-world data. It also supports various file formats such as Excel
, CSV
, SQL
, and more.
We can easily import this package by using the command below.
import pandas as pd
But before we import this package, we need to install this package first in our python environment. So we need to install it using the pip
like below.
pip install pandas
Or, if some of you are using Anaconda
, then we can use the command below.
conda install pandas
Reasons for importerror: install xlrd for excel support
The importerror
occurs when our code fails to import any specific module. For example, sometimes, when we try to import data from an excel file with pandas
using a simple script like the one below.
import pandas as pd
df2 = pd.read_excel("data.xlsx")
print(df2.head(3))
print(df2.tail(3))
We may get the below error message in our console.
ImportError: Install xlrd >= 0.9.0 for Excel support
This error mainly occurs when our script fails to load and read the excel file because of another package named xlrd
. The xlrd
is a unique library that enables us to read and format information for the excel file.
It uses the excel file in the .xls
format. Therefore, if we get the above error, we must install the package to execute the above command successfully.
Solution for importerror: install xlrd for excel support
Suppose we see the above error while executing a script with the pandas
package to load and read an excel file. Then we need to install the xlrd
package in our Python environment first.
We also can install this package using the pip
as follows:
pip install xlrd
Or, we can use the following command using Anaconda
.
conda install -c anaconda xlrd
After successfully installing the package file, we can run our script smoothly.
Aminul Is an Expert Technical Writer and Full-Stack Developer. He has hands-on working experience on numerous Developer Platforms and SAAS startups. He is highly skilled in numerous Programming languages and Frameworks. He can write professional technical articles like Reviews, Programming, Documentation, SOP, User manual, Whitepaper, etc.
LinkedInRelated Article - Python Error
- Can Only Concatenate List (Not Int) to List in Python
- How to Fix Value Error Need More Than One Value to Unpack in Python
- How to Fix ValueError Arrays Must All Be the Same Length in Python
- Invalid Syntax in Python
- How to Fix the TypeError: Object of Type 'Int64' Is Not JSON Serializable
- How to Fix the TypeError: 'float' Object Cannot Be Interpreted as an Integer in Python