I am using a saved Xgboost
model in a executable file created with PyInstaller
. I setup a virtual env and downloaded Xgboost
and ensured it ran but after I create the exe and run the exe I get an error about xgboost.core
:
ModuleNotFoundError: No module nemed 'xgboost.core'
Actually I can't see any import problem with xgboost, first, make sure that you are using the latest version inside your env with pip install -U xgboost
next try to add xgboost.core
as a hidden-import
and add xgboost's DLLs as data-files
.
Suppose that your virtualenv is named env
, use below command to generate your executable:
├───myscript.py
├───env
Code:
import traceback
try:
from xgboost import core
input("xgboost.core imported successfully!")
except Exception:
traceback.print_exc()
input("Import Error!")
Command:
(env) > pyinstaller myscript.py -F --hidden-import=xgboost.core --add-data "./env/xgboost/*;xgboost/"
--add-data "./env/Lib/site-packages/xgboost/VERSION;xgboost/"