python3 pandas模块import报错 ModuleNotFoundError: No module named 'openpyxl'
前言全局说明
ubuntu 18.04
Python 3.8.17
一、环境
ubuntu 18.04
Python 3.8.17
二、报错内容
Traceback (most recent call last):
File "/home/qt/.local/lib/python3.8/site-packages/pandas/compat/_optional.py", line 142, in import_optional_dependency
module = importlib.import_module(name)
File "/usr/local/python3817/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, 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 "/home/qt/.local/lib/python3.8/site-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
File "/home/qt/.local/lib/python3.8/site-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/qt/.local/lib/python3.8/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/home/qt/.local/lib/python3.8/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "main.py", line 100, in show_jf
df = pd.read_excel('jf.xlsx')
File "/home/qt/.local/lib/python3.8/site-packages/pandas/io/excel/_base.py", line 478, in read_excel
io = ExcelFile(io, storage_options=storage_options, engine=engine)
File "/home/qt/.local/lib/python3.8/site-packages/pandas/io/excel/_base.py", line 1513, in __init__
self._reader = self._engines[engine](self._io, storage_options=storage_options)
File "/home/qt/.local/lib/python3.8/site-packages/pandas/io/excel/_openpyxl.py", line 548, in __init__
import_optional_dependency("openpyxl")
File "/home/qt/.local/lib/python3.8/site-packages/pandas/compat/_optional.py", line 145, in import_optional_dependency
raise ImportError(msg)
三、解决方法
pip install openpyxl
四、
免责声明:本号所涉及内容仅供安全研究与教学使用,如出现其他风险,后果自负。
参考、来源:
https://blog.csdn.net/gufenchen/article/details/102053503