'ReadOnlyWorksheet' object has no attribute 'defined_names'
Question:
Whenever I try to read Excel using
part=pd.read_excel(path,sheet_name = mto_sheet)
I get this exception:
<class ‘Exception’> ‘ReadOnlyWorksheet’ object has no attribute ‘defined_names’
This is if I use Visual Studio Code and Python 3.11. However, I don’t have this problem when using Anaconda. Any reason for that?
Answers:
The error seems to be caused by the latest version of openpyxl
.
You can fix it by downgrading to a lower version
pip install --force-reinstall -v "openpyxl==3.1.0"
Possible workaround: create new worksheet inside excel file but leave default name ("Sheet1" etc.) and copy and paste data here…
(tested on Python 3.10.9 + openpyxl==3.1.1)
Whenever I try to read Excel using
part=pd.read_excel(path,sheet_name = mto_sheet)
I get this exception:
<class ‘Exception’> ‘ReadOnlyWorksheet’ object has no attribute ‘defined_names’
This is if I use Visual Studio Code and Python 3.11. However, I don’t have this problem when using Anaconda. Any reason for that?
The error seems to be caused by the latest version of openpyxl
.
You can fix it by downgrading to a lower version
pip install --force-reinstall -v "openpyxl==3.1.0"
Possible workaround: create new worksheet inside excel file but leave default name ("Sheet1" etc.) and copy and paste data here…
(tested on Python 3.10.9 + openpyxl==3.1.1)