xlrd.biffh.XLRDError: Excel xlsx file; not supported
问题描述
今天在测试 python 读取excel文件的时候出现了异常
Traceback (most recent call last): File "E:/worksp_py/hardwary/100day/thirtfive/testxml.py", line 5, in <module> wb = xlrd.open_workbook("./test.xlsx") File "E:\Tools\anaconda3\envs\pytorch\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
好像是 pip 安装的 xlrd 默认版本不支持读取 xlsx
解决方式
先卸载
E:\worksp_py\hardwary>pip uninstall xlrd Found existing installation: xlrd 2.0.1 Uninstalling xlrd-2.0.1: Would remove: e:\tools\anaconda3\lib\site-packages\xlrd-2.0.1.dist-info\* e:\tools\anaconda3\lib\site-packages\xlrd\* e:\tools\anaconda3\scripts\runxlrd.py Proceed (Y/n)? y Successfully uninstalled xlrd-2.0.1
安装低版本xlrd
pip install xlrd==1.2.0
另一个解决方式将 xlsx 另存为 xls