Traceback (most recent call last): File "D:\python\Lib\tkinter_init_.py", line 1948, in call return self.func(*args) ^^^^^^^^^^^^^^^^ File "C:\Users\13923\Desktop\2\主页面.py", line 81, in check Home(self.window) File "C:\Users\13923\Desktop\2\主页面.py", line 120, in init self.readExcel() File "C:\Users\13923\Desktop\2\主页面.py", line 127, in readExcel self.head = pd.read_excel("1.xlsx").columns.tolist() ^^^^^^^^^^^^^^^^^^^^^^^ File "D:\python\Lib\site-packages\pandas\io\excel_base.py", line 478, in read_excel io = ExcelFile(io, storage_options=storage_options, engine=engine) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\python\Lib\site-packages\pandas\io\excel_base.py", line 1513, in init self._reader = self._engines[engine](self._io, storage_options=storage_options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\python\Lib\site-packages\pandas\io\excel_openpyxl.py", line 548, in init import_optional_dependency("openpyxl") File "D:\python\Lib\site-packages\pandas\compat_optional.py", line 145, in import_optional_dependency raise ImportError(msg) ImportError: Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl.
时间: 2023-07-21 20:42:15 浏览: 309
PyPI 官网下载 | friendly_traceback-0.3.153.tar.gz
这段代码的错误是由于缺少openpyxl库所致。openpyxl是一个用于读写Excel 2010 xlsx/xlsm/xltx/xltm文件的Python库。在这里,pandas库调用了openpyxl库来读取Excel文件,但是你的环境中没有安装openpyxl库。因此,你需要使用pip或conda安装openpyxl库。你可以在终端或命令行中运行以下命令来安装它:
```
pip install openpyxl
```
或
```
conda install openpyxl
```
安装后,你的代码应该可以正常工作。
阅读全文