-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getiterator deprecated in Python 3.9; failure to call pd.read_excel() #37795
Comments
Could you provide a copy-pastable example? |
@zilbert97 Do you know which engine pandas is using for your file? If it is xlrd, #28547 seems related:
If xlrd is no longer working with python 3.9, it would be good to address that before 1.2 is released @WillAyd |
Sure! I hope this is what you mean - simply running two lines at the command line can reproduce the error. Python 3.8.1 works fine (created a virtual environment): import pandas as pd
df = pd.read_excel('ZipZag Trolley Monitoring.xlsx') But Python 3.9.0 does not work: import pandas as pd
df = pd.read_excel('ZipZag Trolley Monitoring.xlsx')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/ZG/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pandas/util/_decorators.py", line 296, in wrapper
return func(*args, **kwargs)
File "/Users/ZG/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pandas/io/excel/_base.py", line 304, in read_excel
io = ExcelFile(io, engine=engine)
File "/Users/ZG/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pandas/io/excel/_base.py", line 867, in __init__
self._reader = self._engines[engine](self._io)
File "/Users/ZG/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pandas/io/excel/_xlrd.py", line 22, in __init__
super().__init__(filepath_or_buffer)
File "/Users/ZG/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pandas/io/excel/_base.py", line 353, in __init__
self.book = self.load_workbook(filepath_or_buffer)
File "/Users/ZG/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pandas/io/excel/_xlrd.py", line 37, in load_workbook
return open_workbook(filepath_or_buffer)
File "/Users/ZG/.pyenv/versions/3.9.0/lib/python3.9/site-packages/xlrd/__init__.py", line 130, in open_workbook
bk = xlsx.open_workbook_2007_xml(
File "/Users/ZG/.pyenv/versions/3.9.0/lib/python3.9/site-packages/xlrd/xlsx.py", line 812, in open_workbook_2007_xml
x12book.process_stream(zflo, 'Workbook')
File "/Users/ZG/.pyenv/versions/3.9.0/lib/python3.9/site-packages/xlrd/xlsx.py", line 266, in process_stream
for elem in self.tree.iter() if Element_has_iter else self.tree.getiterator():
AttributeError: 'ElementTree' object has no attribute 'getiterator'
It looks like it is xlrd that is being used - thanks for linking the issue! |
Does it work with with the |
Same problem here. |
there is a PR outstanding to do this just needs some TLC |
Also interesting is that even if
|
#35029 was just merged: the default engine is in most cases now |
It might be a wrong answer. Python==3.9.5 and xlrd==1.2.0 works well on my PC. |
I've read here https://stackoverflow.com/a/64744395 that
getiterator
has been deprecated in Python 3.9.0. My script ran without issues until upgrading Python to 3.9, and now I get the following error:Running Python 3.9.0, Pandas 1.1.4
The text was updated successfully, but these errors were encountered: