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

家住魔仙堡 提交于 2019-12-07 14:58:41

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/51227745/importerror-install-xlrd-0-9-0-for-excel-support-when-using-pd-readexcel-to

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!