python使用pyinstaller封装后报缺少模块错误
使用pyinstaller -F data_tool.py打包后,报错:
Exception in Tkinter callback
Traceback (most recent call last):
File "tkinter\__init__.py", line 1883, in __call__
File "data_tool.py", line 59, in data_deal
data = pd.read_excel(str(self.x.get()))
File "site-packages\pandas\io\excel\_base.py", line 304, in read_excel
File "site-packages\pandas\io\excel\_base.py", line 824, in __init__
File "site-packages\pandas\io\excel\_xlrd.py", line 20, in __init__
File "site-packages\pandas\compat\_optional.py", line 92, in import_optional_dependency
ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.
在这次打包之前,安装python38版本后,安装了pandas,tk,pyinstaller并没有安装xlrd,打包完成后发成这个错误。
pip install xlrd
之后还是依然报这个错误。
办法:安装xlrd之后,在新目录下对.py重新进行打包,或者删除之前打包生成的文件
删除后再重新打包pyinstaller -F data_tool.py