Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: Install xlrd >= 0.9.0 for Excel support when using pd.readexcel to read .xlsx file : never happened before

Tags:

pandas

xlsx

Something strange is going on. Just today when trying to read in a dataframe from an xlsx file:

import pandas as pd
df = pd.read_excel('vlnew.xlsx',sheet_name='Sheet1') 

I am getting the following error: ImportError: Install xlrd >= 0.9.0 for Excel support

I am fully aware that plain and simple the instructions are to install xlrd, but I should not have to install xlrd when I was never getting this error before, and also, xlrd only applies to the old .xls file format. I am using .xlsx.

I can't understand why today all of a sudden this error is popping up. This is very strange indeed, at least to me.

Update: When I execute this script in the Spyder IDE, I do not get the xlrd import error, but just today I ran this script in the Conda command prompt and only then does it report the xlrd error. Why are there inconsistencies between the Conda command prompt and Spyder IDE?

like image 564
GusG Avatar asked Jul 07 '18 23:07

GusG


2 Answers

Try writing following command into the terminal pip install xlrd

And then import the xlrd alongside with pandas import xlrd and import pandas as pd

like image 168
BanditoKubito Avatar answered Oct 22 '22 10:10

BanditoKubito


I was getting an error "ImportError: Install xlrd >= 1.0.0 for Excel support" on Pycharm for below code

import pandas as pd
df2 = pd.read_excel("data.xlsx")
print(df2.head(3))
print(df2.tail(3))

Solution : pip install xlrd

It resolved error after using this.

Also no need to use "import xlrd" in program

like image 38
Omkar Avatar answered Oct 22 '22 10:10

Omkar