关于xlrd最新版本不支持.xlsx文件的解决办法
这是很久之前我就遇到的一个问题,这次又遇到了,发现之前没有写笔记,这次记录一下。
报错信息
File "D:\Y_Script\OTATool_1_1_9\commonFiles\readExcelFile.py", line 7, in __init__ self.xl = xlrd.open_workbook('{}'.format(filename)) File "D:\G_Working\Z_Z_python_environment\environment\OTATool_AbouTabletTool\venv\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
python安装最新版本的xlrd不支持读取.xlsx的excel文件
需要回退到xlrd1.2.0版本
#卸载已安装的 pip uninstall xlrd #下载对应的版本 pip install xlrd==1.2.0
C:\Users\Lvan8>pip uninstall xlrd Found existing installation: xlrd 2.0.1 Uninstalling xlrd-2.0.1: Would remove: d:\g_working\z_z_python_environment\environment\otatool_aboutablettool\venv\lib\site-packages\xlrd-2.0.1.dist-info\* d:\g_working\z_z_python_environment\environment\otatool_aboutablettool\venv\lib\site-packages\xlrd\* d:\g_working\z_z_python_environment\environment\otatool_aboutablettool\venv\scripts\runxlrd.py Proceed (y/n)? y Successfully uninstalled xlrd-2.0.1 C:\Users\Lvan8>pip install xlrd==1.2.0 Collecting xlrd==1.2.0 Using cached xlrd-1.2.0-py2.py3-none-any.whl (103 kB) Installing collected packages: xlrd Successfully installed xlrd-1.2.0
回退完成后正常运行。