ModuleNotFoundError
pip show joblib
1 pip show joblib
Name: joblib
Version: 1.3.2
Summary: Lightweight pipelining with Python functions
Home-page:
Author:
Author-email: Gael Varoquaux <gael.varoquaux@normalesup.org>
License: BSD 3-Clause
Location: C:\Python311\Lib\site-packages
Requires:
Required-by: scikit-learn
2 修改 spec文件:
a = Analysis(
['predictApp.py'],
pathex=['C:\\Python311\Lib\\site-packages\\site-packages'],
binaries=[],
datas=[('random_forest_input_model2.pkl', 'models')],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
)
FileNotFoundError: [Errno 2] No such file or directory
Traceback (most recent call last):
File "predictApp.py", line 19, in <module>
File "predictApp.py", line 16, in load_model
FileNotFoundError: [Errno 2] No such file or directory: 'models\\random_forest_input_model2.pkl'
[41680] Failed to execute script 'predictApp' due to unhandled exception!
Pyinstaller -F -w predictApp.py --add-data=random_forest_input_model2.pkl:. 如果放在二级目录下 Pyinstaller -F -w predictApp.py --add-data=random_forest_input_model2.pkl:models
等同于修改spec文件:
a = Analysis(
['predictApp.py'],
pathex=['C:\\Python311\Lib\\site-packages\\site-packages'],
binaries=[],
datas=[('random_forest_input_model2.pkl', 'models')],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
)