用pandas读xlsx文件时报错:
/usr/python3/lib/python3.8/site-packages/xlrd/__init__.py in open_workbook(filename, logfile, verbosity, use_mmap, file_contents, encoding_override, formatting_info, on_demand, ragged_rows, ignore_workbook_corruption)
168 # files that xlrd can parse don't start with the expected signature.
169 if file_format and file_format != 'xls':
--> 170 raise XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+'; not supported')
171
172 bk = open_workbook_xls(
XLRDError: Excel xlsx file; not supported

这是由于新版本的xlrd只支持xls文件
解决办法:
- 安装旧版本xlrd
>>> pip3 install xlrd==

本文介绍了解决pandas读取xlsx文件时遇到的Excel xlsx file; not supported错误的方法。该错误源于xlrd新版本不再支持xlsx格式。解决方式有两种:一是回退xlrd版本至1.2.0;二是采用openpyxl作为解析引擎。
最低0.47元/天 解锁文章
4387





