用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