pandas读excel类型文件报错: xlrd.biffh.XLRDError: Excel xlsx file; not supported

216 阅读1分钟

一、问题

pandas 读取 Excel 文件(.xlsx)时报错如下:

raise XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+'; not supported')
xlrd.biffh.XLRDError: Excel xlsx file; not supported

二、报错原因

xlrd 版本过低,只支持读取 .xls 文件

三、解决方案

1、方法一

先卸载低版本的 xlrd,然后安装新版本:

pip uninstall xlrd
pip install xlrd==1.2.0

或者使用 conda 卸载和安装:

conda uninstall xlrd
conda install xlrd=1.2.0

2、方法二

用 openpyxl 代替 xlrd 打开 .xlsx 文件:

df = pandas.read_excel(‘data.xlsx’,engine='openpyxl')

创作打卡挑战赛

赢取流量/现金/CSDN周边激励大奖