报错示例
test@B-524QQ6LT-0149 python-excel % python3 ceshi.py
Traceback (most recent call last):
File "ceshi.py", line 3, in <module>
data = xlrd.open_workbook(r"007_服务器上架表.xls")
File "/Users/songzekai/Library/Python/3.8/lib/python/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包,只支持.xls文件。需要删除已经安装的xlrd,安装老版本
//删除时可看到部署的xlrd版本为2.0.1
test@B-524QQ6LT-0149 python-excel % pip3 uninstall xlrd
Found existing installation: xlrd 2.0.1
Uninstalling xlrd-2.0.1:
Would remove:
/Users/songzekai/Library/Python/3.8/bin/runxlrd.py
/Users/songzekai/Library/Python/3.8/lib/python/site-packages/xlrd-2.0.1.dist-info/*
/Users/songzekai/Library/Python/3.8/lib/python/site-packages/xlrd/*
Proceed (Y/n)? y
Successfully uninstalled xlrd-2.0.1
//安装低版本的xlrd
test@B-524QQ6LT-0149 python-excel % pip3 install xlrd==1.2.0
Defaulting to user installation because normal site-packages is not writeable
Collecting xlrd==1.2.0
Downloading xlrd-1.2.0-py2.py3-none-any.whl (103 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 103.3/103.3 kB 923.0 kB/s eta 0:00:00
Installing collected packages: xlrd
Successfully installed xlrd-1.2.0