用xlrd打开1.xlsx表格报错:xlrd_init_.py XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+’; not supported’)
xlrd.biffh.XLRDError: Excel xlsx file; not supported
项目场景:
用xlrd打开1.xlsx表格报错
问题描述
D:\Install\Python3.8.1\python.exe D:/WorkSpase/pythonProject/pythonProject/demo03/test.py
Traceback (most recent call last): File “D:/WorkSpase/pythonProject/pythonProject/demo03/test.py”, line 3, in xlsx = xlrd.open_workbook(‘1.xlsx’) File “D:\Install\Python3.8.1\lib\site-packages\xlrd_init_.py”, line 170, in open_workbook raise XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+’; not supported’)
xlrd.biffh.XLRDError: Excel xlsx file; not supported
D:\Install\Python3.8.1\python.exe D:/WorkSpase/pythonProject/pythonProject/demo03/test.py
Traceback (most recent call last):
File "D:/WorkSpase/pythonProject/pythonProject/demo03/test.py", line 3, in <module>
xlsx = xlrd.open_workbook('1.xlsx')
File "D:\Install\Python3.8.1\lib\site-packages\xlrd\__init__.py", line 170, in open_workbook
raise XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+'; not supported')
xlrd.biffh.XLRDError: Excel xlsx file; not supported
原因分析:
安装的xlrd是最新版:xlrd-2.0.1 不支持.xlsx文件,卸载已安装的xlrd-2.0.1,安装低版本的xlrd-1.2.0。
解决方案:
1.卸载已安装的xlrd-2.0.1 (直接复制以下命令到terminal):
pip uninstall xlrd
2.安装低版本的xlrd (直接复制以下命令到terminal):
pip install xlrd==1.2.0
本文档讲述了在使用Python库xlrd处理1.xlsx文件时遇到的错误,原因在于xlrd-2.0.1版本不支持.xlsx格式。通过卸载旧版本并安装低版本xlrd-1.2.0,解决了此问题。
814

被折叠的 条评论
为什么被折叠?



