2

I am trying to open an xlsx file with Pandas and i recieve this error:

Output exceeds the size limit. Open the full output data in a text editor
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[20], line 1
----> 1 df = pd.read_excel("C:/Users/*****/OneDrive - *******/Bureau/file_name.xlsx", sheet_name="")

File c:\Users\*******\OneDrive - ********\Bureau\file_name\venv\lib\site-packages\pandas\util\_decorators.py:211, in deprecate_kwarg.<locals>._deprecate_kwarg.<locals>.wrapper(*args, **kwargs)
    209     else:
    210         kwargs[new_arg_name] = new_arg_value
--> 211 return func(*args, **kwargs)

File c:\Users\******\OneDrive - *******\Bureau\file_name\venv\lib\site-packages\pandas\util\_decorators.py:331, in deprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper(*args, **kwargs)
    325 if len(args) > num_allow_args:
    326     warnings.warn(
    327         msg.format(arguments=_format_argument_list(allow_args)),
    328         FutureWarning,
    329         stacklevel=find_stack_level(),
    330     )
--> 331 return func(*args, **kwargs)

File c:\Users\******\OneDrive - ******\Bureau\file_name\venv\lib\site-packages\pandas\io\excel\_base.py:482, in read_excel(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, parse_dates, date_parser, thousands, decimal, comment, skipfooter, convert_float, mangle_dupe_cols, storage_options)
    480 if not isinstance(io, ExcelFile):
    481     should_close = True
--> 482     io = ExcelFile(io, storage_options=storage_options, engine=engine)
    483 elif engine and engine != io.engine:
    484     raise ValueError(
...
--> 109     sheet.defined_names[name] = defn
    111 elif reserved == "Print_Titles":
    112     titles = PrintTitles.from_string(defn.value)

AttributeError: 'ReadOnlyWorksheet' object has no attribute 'defined_names'
"

I was using python 3.10. versions and tried it with 3.11.2 also and version of pandas is 1.5.3 also i tried the solution in this topic too;

'ReadOnlyWorksheet' object has no attribute 'defined_names'

i downgraded openpyxl and upgraded it again, tried several times but nope. still getting the same error. I tried different file xlsm, worked fine but not with xlsx.

so i am blocked atm!

  • i did nothing but to my surprise, it started working by itself! do not know may be i closed vs code and restart it after lunch but now it is working as it should be. – Gorkem Tunc Mar 01 '23 at 12:52

2 Answers2

4

As explained here, need to downgrade to 3.1.0:

pip install --force-reinstall -v "openpyxl==3.1.0"
Maxime
  • 594
  • 5
  • 17
1

Restart Kernel.

Had the same problem, downgraded openpyxl version to the 3.1.0, still wasn't working.

Did a restart and runned it again.

Worked!