python3.6 使用pandas读取xlsx出错 not supported

博主使用pandas处理数据,在read_excel时报错。经搜索发现,是因为xlrd更新到2.0.1版本后只支持.xls文件,导致读取.xlsx文件报错。解决办法一是安装旧版xlrd,二是用openpyxl代替xlrd打开.xlsx文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天想把数据处理用pandas来处理。计划很完美。然后就在第一步read-excle中的时候就报错了。一股脑的查看官方文档,

https://www.pypandas.cn/docs/ 也是如此调用。到底是哪里出错了呢?

一股脑的傻劲想要放弃。算了,搜索一下吧。 整理如下:

原因是最近xlrd更新到了2.0.1版本,只支持.xls文件。

所以pandas.read_excel(‘xxx.xlsx’)会报错。

 安装旧版xlrd,在cmd中运行:

pip uninstall xlrd
pip install xlrd==1.2.0

也可以用openpyxl代替xlrd打开.xlsx文件:

df=pandas.read_excel(‘data.xlsx’,engine=‘openpyxl’)

 

Traceback (most recent call last): File "C: Users Idell AppData Local Programs Python Python3612. py”,line 3, inく module> df = pd. read_excel(r"C: \Usersldell\Downloads\第二章素材文件一实验项目二\第二 章素材文件一实验项目二\实验项目二\实验任务四\商品销售数据.xlsx”) File ”C: Users Idell lAppData Local lPrograms Python Python36lliblsite-packages lp andaslutill_decorators. py,line 296,in wrapper return func(*args, **kwargs) File”c: Users Ide ÍI AppData Local \Programs IPython Python36lliblsite-packages lp andasliolexcell_base. py”,line 304, in read_excel io = ExcelFile(io, engine=engine) File ”C: Usersldell AppData Local Programs lPython Python36 liblsite-packages lp andasliolexcell_base. py”,line 867, in _init_ self._reader = self._engines[engineT(self.Lio) File”C: Users Idell lAppData Local Programs lPython Python36lliblsite-packages Ip andasliolexcelLxlrd.py”,line 22, in _init__ super().__init_(filepath_or_buffer) File "C: Usersl deÏI lAppDataÏLocal \Programs Python Python36 liblsite-packageslp andasliolexcell_base. py”,line 353in _init__ self. book = self. load_ workbook(filepath_or_buffer) File ”c: Users IdelI lAppÕata Local Programs lPython Python36lliblsite-packages Ip andasliolexcell_xlrd. py”, line 37, in load_workbook return open_workbook(filepath_or_buffer) File "C: lUsersldelI AppData Local lPrograms Python Python36\liblsite-packageslx lrdl init _.py, line i70, in open_workbook raise XIRDError (FILE_FORMAT_DESCRIPTIOIS[file_format]+'; not supported' ) xlrd. biffh. XLRDError: Excel xlsx file; not supported
最新发布
03-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值