[ error message ]
>>> df = pd.read_excel('data.xlsx')
Traceback (most recent call last):
File "C:\devel\Python\Python39\lib\site-packages\pandas\compat\_optional.py", line 138, in import_optional_dependency
module = importlib.import_module(name)
File "C:\devel\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'openpyxl'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\devel\Python\Python39\lib\site-packages\pandas\util\_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "C:\devel\Python\Python39\lib\site-packages\pandas\io\excel\_base.py", line 457, in read_excel
io = ExcelFile(io, storage_options=storage_options, engine=engine)
File "C:\devel\Python\Python39\lib\site-packages\pandas\io\excel\_base.py", line 1419, in __init__
self._reader = self._engines[engine](self._io, storage_options=storage_options)
File "C:\devel\Python\Python39\lib\site-packages\pandas\io\excel\_openpyxl.py", line 524, in __init__
import_optional_dependency("openpyxl")
File "C:\devel\Python\Python39\lib\site-packages\pandas\compat\_optional.py", line 141, in import_optional_dependency
raise ImportError(msg)
ImportError: Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl.
[ solution ]
openpyxl module install
>>> pip install openpyxl
PS C:\devel> pip install openpyxl
Collecting openpyxl
Downloading openpyxl-3.1.2-py2.py3-none-any.whl (249 kB)
|████████████████████████████████| 249 kB 3.3 MB/s
Collecting et-xmlfile
Downloading et_xmlfile-1.1.0-py3-none-any.whl (4.7 kB)
Installing collected packages: et-xmlfile, openpyxl
Successfully installed et-xmlfile-1.1.0 openpyxl-3.1.2
WARNING: You are using pip version 21.1.3; however, version 23.3.1 is available.
You should consider upgrading via the 'c:\devel\python\python39\python.exe -m pip install --upgrade pip' command.
>>> df = pd.read_excel('data.xlsx')
>>> print(df)
Num Name
0 1 James
1 2 Semi
2 3 Bob