当前位置:网站首页>【bug】XLRDError: Excel xlsx file; not supported
【bug】XLRDError: Excel xlsx file; not supported
2022-07-29 05:21:00 【机器不学习我学习】
今天儿童节,记录一个bug。
楼主写的一套代码是在公司的台式机上,今天需要下基层,就把项目代码拷贝到U盘,然后在基层用笔记本运行代码的时候出现:
raise ImportError(msg) from None
ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.
其实出现这个报错的时候,我就很惊讶。。。因为之前在笔记本上运行过类似的代码(相同环境下),今天怎么就不行了。
根据提示,安装了xlrd
pip install xlrd
然后,再运行代码出现:
raise XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+'; not supported')
XLRDError: Excel xlsx file; not supported
楼主表示很无奈。。。
解决办法:
出错的语句:
data = pd.read_excel('www.xlsx', sheet_name='C1')
在后面加engine=‘openpyxl’,解决问题
data = pd.read_excel('www.xlsx', sheet_name='C1',engine='openpyxl')
大总结:
原因是pip安装的是最新的xlrd包,只支持.xls文件。所以pd.read_excel(‘xxx.xlsx’)会报错
解决方法1: 安装旧版xlrd
pip uninstall xlrd
pip install xlrd=1.2.0
解决方案2: 使用openpyxl包
pd.read_excel(‘xxx.xlsx’, engine=‘openpyxl’)
友情提醒:
代码移植(运行)时,一定要配置相同的环境,python版本,相应依赖库的版本。
参考:
https://blog.csdn.net/m0_67457639/article/details/123746623
https://www.jianshu.com/p/ee893ecae0f5
边栏推荐
- My ideal job, the absolute freedom of coder farmers is the most important - the pursuit of entrepreneurship in the future
- 通过简单的脚本在Linux环境实现Mysql数据库的定时备份(Mysqldump命令备份)
- datax安装
- ReportingService WebService Form身份验证
- isAccessible()方法:使用反射技巧让你的性能提升数倍
- Plato farm is expected to further expand its ecosystem through elephant swap
- Activity交互问题,你确定都知道?
- [database] database course design - vaccination database
- C# 连接 SharepointOnline WebService
- Android studio login registration - source code (connect to MySQL database)
猜你喜欢

Show profiles of MySQL is used.

mysql 的show profiles 使用。

闪贷Dapp的调研及实现

Super simple integration of HMS ml kit to realize parent control

Detailed explanation of MySQL statistical function count
![30 knowledge points that must be mastered in quantitative development [what is level-2 data]](/img/cc/8eb2f0b11679af57e196f6e6d828f8.png)
30 knowledge points that must be mastered in quantitative development [what is level-2 data]

【数据库】数据库课程设计一一疫苗接种数据库

Realize the scheduled backup of MySQL database in Linux environment through simple script (mysqldump command backup)

Training log 6 of the project "construction of Shandong University mobile Internet development technology teaching website"

与张小姐的春夏秋冬(3)
随机推荐
Flutter 绘制技巧探索:一起画箭头(技巧拓展)
Training log 4 of the project "construction of Shandong University mobile Internet development technology teaching website"
Android studio login registration - source code (connect to MySQL database)
Markdown语法
Windos下安装pyspider报错:Please specify --curl-dir=/path/to/built/libcurl解决办法
Android Studio 实现登录注册-源代码 (连接MySql数据库)
微信内置浏览器禁止缓存的问题
Thinkphp6 output QR code image format to solve the conflict with debug
华为2020校招笔试编程题 看这篇就够了(上)
中海油集团,桌面云&网盘存储系统应用案例
Starfish OS: create a new paradigm of the meta universe with reality as the link
Okaleido tiger logged into binance NFT on July 27, and has achieved good results in the first round
初探fastJson的AutoType
全闪分布式,如何深度性能POC?
Flink connector Oracle CDC 实时同步数据到MySQL(Oracle19c)
Go|gin quickly use swagger
Markdown syntax
Ribbon学习笔记二
突破硬件瓶颈(一):Intel体系架构的发展与瓶颈挖掘
"Shandong University mobile Internet development technology teaching website construction" project training log V