我使用以下命令为我的大型Python脚本创建了一个exe文件-
pyinstaller gui_final.py --onefile --hidden-import=sklearn --hidden-import=ipaddress --hidden-import=PIL --hidden-import=pickle --hidden-import=shutil --hidden-import=joblib
个
在我使用JOBLIB加载我的决策树模型文件(dtree.joblib)之前,exe文件运行良好.
clf = joblib.load("dtree.joblib")
弹出以下错误-Here is the complete error in the terminal:
ModuleNotFoundError: No module named 'sklearn.ensemble._weight_boosting'
我try 更新HIDDEN_IMPORTS,只将sklearn.ensemble
和sklearn.ensemble._weight_boostin
添加到exe的规范文件中,按照this答案中的步骤操作.下面还给出了步骤
from PyInstaller.utils.hooks import collect_submodules
hidden_imports = collect_submodules('sklearn.ensemble') #('sklearn.ensemble._weight_boosting')
a = Analysis(['gui_final.py'],
binaries=None,
datas=[],
hiddenimports=hidden_imports,
.
.
通过运行以下命令:
pyinstaller gui_final.spec
但在运行可执行文件后仍出现与之前相同的ModuleNotFoundError.
我try 使用pyinstaller查看一些有关joblib的问题,但没有找到任何合适的问题或解决方案.
有没有人能建议一些步骤,让脚本的可执行文件可运行?