xlrd库报错【AttributeError: ‘ElementTree‘ object has no attribute ‘getiterator‘】

简介: xlrd库报错【AttributeError: ‘ElementTree‘ object has no attribute ‘getiterator‘】

使用python3.9读取excel时报错AttributeError: 'ElementTree' object has no attribute 'getiterator'


出现错误的原因


在新版python3.9中,windows中使用的更新删除了getiterator方法,所以我们老版本的xlrd库调用getiterator方法时会报错。AttributeError: 'ElementTree' object has no attribute 'getiterator'


解决方法


wind中找出目录python\Lib\site-packages\xlrd下的xlsx.py文件,

1696842343833.jpg

如果找不到文件地址,可以使用wind+R,输入cmd 输入pip show xlrd即可找到xlrd的文件地址:

1696842444600.jpg

修改两个地方的的getiterator()改成iter(),下面的两个地方,这里已经把getiterator()改成iter()了

1696842467033.jpg

1696842477387.jpg

然后重新载入程序就解决了。

目录
相关文章
|
2月前
|
计算机视觉 Python
解决 NoneType‘ object has no attribute ‘astype’ 问题
解决 NoneType‘ object has no attribute ‘astype’ 问题
30 0
|
6月前
|
存储 JSON 数据格式
数据集加载时报错'dict' object has no attribute 'requests‘
数据集加载时报错'dict' object has no attribute 'requests‘
113 5
|
4月前
AttributeError: 'NoneType' object has no attribute 'to_capabilities'
AttributeError: 'NoneType' object has no attribute 'to_capabilities'
377 0
|
5月前
|
JSON 数据格式
解决报错TypeError: Converting circular structure to JSON --> starting at object with constructor
解决报错TypeError: Converting circular structure to JSON --> starting at object with constructor
|
4月前
AttributeError ‘NoneType‘ object has no attribute ‘to_capabilities‘
AttributeError ‘NoneType‘ object has no attribute ‘to_capabilities‘
93 0
|
5月前
|
数据采集
运行爬虫时报错AttributeError—— 'str' object has no attribute 'capabilities'
运行爬虫时报错AttributeError—— 'str' object has no attribute 'capabilities'
255 0
|
5月前
'WebDriver' object has no attribute 'find_element_by_tag_name'
'WebDriver' object has no attribute 'find_element_by_tag_name'
118 0
|
5月前
报错modify sync object Modify sync object Failed!
报错modify sync object Modify sync object Failed!
21 1
|
6月前
|
Java
java判断Object对象是否为空demo
java判断Object对象是否为空demo
|
20天前
|
JavaScript
js 字符串String转对象Object
该代码示例展示了如何将一个以逗号分隔的字符串(`'1.2,2,3,4,5'`)转换为对象数组。通过使用`split(',')`分割字符串并`map(parseFloat)`处理每个元素,将字符串转换成浮点数数组,最终得到一个对象数组,其类型为`object`。