python:xlrd.biffh.XLRDError: Excel xlsx file; not supported
1. 问题描述LZ使用xlrd读取file.xlsx的文档时,运行程序报错Traceback (most recent call last):File "<input>", line 1, in <module>File "/root/.pycharm_helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfi
·
1. 问题描述
LZ使用xlrd读取file.xlsx的文档时,运行程序报错
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/root/.pycharm_helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/root/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/fanrongrong/sentence-transformers/examples/transformers_tour/test_data/xlsx2txt.py", line 3, in <module>
workbook = xlrd.open_workbook('./jqsj.xlsx')
File "/root/anaconda2/envs/SentenceTrans3.9/lib/python3.9/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
2. 解决方案
就离谱,居然不支持xlsx格式,最终在各种百度之下,找到了解决方案,居然是降版本!
conda install xlrd==1.2.0
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.9.1
latest version: 4.10.1
Please update conda by running
$ conda update -n base -c defaults conda
## Package Plan ##
environment location: /root/anaconda2/envs/SentenceTrans3.9
added / updated specs:
- xlrd==1.2.0
The following packages will be downloaded:
package | build
---------------------------|-----------------
xlrd-1.2.0 | py_0 103 KB defaults
------------------------------------------------------------
Total: 103 KB
The following packages will be DOWNGRADED:
xlrd 2.0.1-pyhd3eb1b0_0 --> 1.2.0-py_0
Proceed ([y]/n)? y
Downloading and Extracting Packages
xlrd-1.2.0 | 103 KB | ############################################################################################################################################################# | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
最后运行程序,问题解决,这个版本更新的意义是?
更多推荐
已为社区贡献2条内容
所有评论(0)