python读取excel文件报错:Excel xlsx file; not supported

报错示例

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
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值