当前位置:网站首页>【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
边栏推荐
- Rsync+inotyfy realize real-time synchronization of single data monitoring
- Nailing alarm script
- 在uni-app项目中,如何实现微信小程序openid的获取
- 通过简单的脚本在Linux环境实现Mysql数据库的定时备份(Mysqldump命令备份)
- Tear the ORM framework by hand (generic + annotation + reflection)
- Basic use of array -- traverse the circular array to find the maximum value, minimum value, maximum subscript and minimum subscript of the array
- 微信小程序源码获取(附工具的下载)
- Ribbon学习笔记二
- Changed crying, and finally solved cannot read properties of undefined (reading 'parsecomponent')
- XDFS&空天院HPC集群典型案例
猜你喜欢

性能对比|FASS iSCSI vs NVMe/TCP
![30 knowledge points that must be mastered in quantitative development [what is individual data]?](/img/13/9e5e44b371d79136e30dd86927ff3a.png)
30 knowledge points that must be mastered in quantitative development [what is individual data]?

XDFS&中国日报社在线协同编辑平台典型案例

Flink, the mainstream real-time stream processing computing framework, is the first experience.

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

Starfish OS: create a new paradigm of the meta universe with reality as the link

FFmpeg创作GIF表情包教程来了!赶紧说声多谢乌蝇哥?

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

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

Simple optimization of interesting apps for deep learning (suitable for novices)
随机推荐
Xsan is highly available - xdfs and San are integrated with new vitality
Detailed explanation of tool classes countdownlatch and cyclicbarrier of concurrent programming learning notes
Reporting Service 2016 自定义身份验证
Rsync+inotyfy realize real-time synchronization of single data monitoring
July 28 ens/usd Value Forecast: ENS attracts huge profits
并发编程学习笔记 之 Lock锁及其实现类ReentrantLock、ReentrantReadWriteLock和StampedLock的基本用法
Starfish OS: create a new paradigm of the meta universe with reality as the link
Idea using JDBC to connect mysql database personal detailed tutorial
识变!应变!求变!
[go] use of defer
以‘智’提‘质|金融影像平台解决方案
Training log II of the project "construction of Shandong University mobile Internet development technology teaching website"
深度学习的趣味app简单优化(适合新手)
How can Plato obtain premium income through elephant swap in a bear market?
iSCSI vs iSER vs NVMe-TCP vs NVMe-RDMA
XDFS&中国日报社在线协同编辑平台典型案例
Fantom (FTM) prices will soar by 20% in the next few days
Tear the ORM framework by hand (generic + annotation + reflection)
『全闪实测』数据库加速解决方案
day02作业之进程管理