当前位置:网站首页>【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
边栏推荐
- Detailed explanation of MySQL statistical function count
- ASM插桩:学完ASM Tree api,再也不用怕hook了
- 重庆大道云行作为软件产业代表受邀参加渝中区重点项目签约仪式
- Detailed steps of JDBC connection to database
- CMD window under Windows connects to MySQL and operates the table
- ReportingService WebService Form身份验证
- Shanzhai coin Shib has a US $548.6 million stake in eth whale's portfolio - traders should be on guard
- Flutter正在被悄悄放弃?浅析Flutter的未来
- 手撕ORM 框架(泛型+注解+反射)
- Training log II of the project "construction of Shandong University mobile Internet development technology teaching website"
猜你喜欢

How to make interesting apps for deep learning with zero code (suitable for novices)

“山东大学移动互联网开发技术教学网站建设”项目实训日志二

C# 连接 SharepointOnline WebService

Detailed explanation of MySQL statistical function count

Flink connector Oracle CDC 实时同步数据到MySQL(Oracle19c)

day02 作业之文件权限

Windos下安装pyspider报错:Please specify --curl-dir=/path/to/built/libcurl解决办法

Ribbon学习笔记二

Changed crying, and finally solved cannot read properties of undefined (reading 'parsecomponent')

并发编程学习笔记 之 工具类Semaphore(信号量)
随机推荐
并发编程学习笔记 之 原子操作类AtomicReference、AtomicStampedReference详解
C# 连接 SharepointOnline WebService
【数据库】数据库课程设计一一疫苗接种数据库
Detailed steps of JDBC connection to database
30 knowledge points that must be mastered in quantitative development [what is individual data]?
iSCSI vs iSER vs NVMe-TCP vs NVMe-RDMA
Activity交互问题,你确定都知道?
[database] database course design - vaccination database
The bear market is slow, and bit.store provides stable stacking products to help you get through the bull and bear market
Super simple integration HMS ml kit face detection to achieve cute stickers
Android Studio 实现登录注册-源代码 (连接MySql数据库)
“山东大学移动互联网开发技术教学网站建设”项目实训日志七
以‘智’提‘质|金融影像平台解决方案
并发编程学习笔记 之 工具类CountDownLatch、CyclicBarrier详解
Changed crying, and finally solved cannot read properties of undefined (reading 'parsecomponent')
“山东大学移动互联网开发技术教学网站建设”项目实训日志二
Flutter正在被悄悄放弃?浅析Flutter的未来
From starfish OS' continued deflationary consumption of SFO, the value of SFO in the long run
"Shandong University mobile Internet development technology teaching website construction" project training log V
Training log II of the project "construction of Shandong University mobile Internet development technology teaching website"