pythonpython-3.xpandas

ImportError: Pandas requires version '3.0.7' or newer of 'openpyxl' (version '3.0.5' currently installed)


I have a strange problem which leads to the message in the title, leading to the error report below.

The fact is: I have (on Linux) Python 3.9.15, Pandas 1.5.2, openpyxl 3.0.10. I do not use venv, and for editing I use Wing, but I do not run scripts from it, only from the shell.

I looked over /usr/lib64/python3.9/site-packages/, but I did not find any other version of openpyxl laying around. What's wrong? I even uninstalled and re-installed both pandas and openpyxl - no effect.

File "./elektreiba-00-02.py", line 140, in <module> main(sys.argv[1:])
  File "./elektreiba-00-02.py", line 79, in main  df = pd.read_excel(infile, sheet_name=None)
  File "/usr/lib64/python3.9/site-packages/pandas/util/_decorators.py", line 211, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib64/python3.9/site-packages/pandas/util/_decorators.py", line 331, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib64/python3.9/site-packages/pandas/io/excel/_base.py", line 482, in read_excel
    io = ExcelFile(io, storage_options=storage_options, engine=engine)
  File "/usr/lib64/python3.9/site-packages/pandas/io/excel/_base.py", line 1695, in __init__
    self._reader = self._engines[engine](self._io, storage_options=storage_options)
  File "/usr/lib64/python3.9/site-packages/pandas/io/excel/_openpyxl.py", line 556, in __init__
    import_optional_dependency("openpyxl")
  File "/usr/lib64/python3.9/site-packages/pandas/compat/_optional.py", line 171, in import_optional_dependency
    raise ImportError(msg)
ImportError: Pandas requires version '3.0.7' or newer of 'openpyxl' (version '3.0.5' currently installed)

Solution

  • It turned out being a cache question. I don't have any idea what created a site-package cache under ~/./local/ and why the Python interpreter looked there at first.