xgboost
xgboost copied to clipboard
Pyinstaller and xgboost
Dear coders,
I am trying to launch pyinstaller for my app but it appear the commun error with xgboost and pyinstaller. I am using xgboost version 1.5.2.
The error is :
import xgboost as xgb
File "
- /tmp/_MEIHMqWQr/xgboost/lib/libxgboost.so
- /tmp/_MEIHMqWQr/xgboost/../../lib/libxgboost.so
- /tmp/_MEIHMqWQr/lib/libxgboost.so XGBoost Python package path: /tmp/_MEIHMqWQr/xgboost sys.prefix: /tmp/_MEIHMqWQr See: https://xgboost.readthedocs.io/en/latest/build.html for installing XGBoost.
I have tray with adding --add-data "path" --add-data"path/VERSION" in the pyinstaller command but did not work.
Any idea about how to solve this problem?
Thanks in advance,
Kind regards, Marc
I don't think XGBoost has been tested with Pyinstaller. If anyone else can jump in and propose a fix, that would be great.
I managed to get something similar working by doing;
pip install pipwin pipwin install xgboost
(The latest xgboost version for pipwin is 1.5.1, which may or may not suit your needs)
and then something like;
pyinstaller your.py -F --onefile --add-data "c:\repos\workspaces.env\lib\site-packages\xgboost\xgboost.dll;xgboost" --add-data "c:\repos\workspaces.env\Lib\site-packages\xgboost\VERSION;xgboost"
Dear JSalter2013, I think that your solution could work for windows but not for Linux. Do you know any solution for linux ubuntu?
Thanks in advance,
@marcrocasalonso There are the same error for me. It bothered me for two days.
There is a solution for it. https://github.com/pyinstaller/pyinstaller/pull/4077/commits/a11e82681b697b36b2690ffa8365acd130b8885d
But that commit do not re-target to the https://github.com/pyinstaller/pyinstaller-hooks-contrib repo.
Temporary, add that hook-xgboost.py into PYTHONHOME/lib/site-package/_pyinstaller_hooks_contrib/hooks/stdhooks
then, use your pyinstaller command, pyinstaller --xxxx --collect-all "xgboost"
There solved my problem.
@zhnnix it works
@marcrocasalonso There are the same error for me. It bothered me for two days.
There is a solution for it. pyinstaller/pyinstaller@a11e826
But that commit do not re-target to the https://github.com/pyinstaller/pyinstaller-hooks-contrib repo.
Temporary, add that hook-xgboost.py into PYTHONHOME/lib/site-package/_pyinstaller_hooks_contrib/hooks/stdhooks
then, use your pyinstaller command, pyinstaller --xxxx --collect-all "xgboost"
There solved my problem.
@zhnnix I confirm that your solution resolves this problem! I got two terrible days and now it's working,
Thank you so much
N: for me works by just launch pyinstaller --onefile --noconfirm -F xxxx.py --collect-all "xgboost"
@marcrocasalonso There are the same error for me. It bothered me for two days.
There is a solution for it. pyinstaller/pyinstaller@a11e826
But that commit do not re-target to the https://github.com/pyinstaller/pyinstaller-hooks-contrib repo.
Temporary, add that hook-xgboost.py into PYTHONHOME/lib/site-package/_pyinstaller_hooks_contrib/hooks/stdhooks
then, use your pyinstaller command, pyinstaller --xxxx --collect-all "xgboost"
There solved my problem.
It works! Thank you so much!
@zhnnix Does this solution work under linux? I didn't find the hook-xgboost.py file, which directory is this file in? I've been stuck with this problem for days Thank you so much!
@Niclouge Yes, it could work under linux.
This hook-xgboost.py file needs to be added manually. Just like pyinstaller/pyinstaller@a11e826.
This is a temporary solution, but it can be solved immediately.
@Niclouge Yes, it could work under linux.
This hook-xgboost.py file needs to be added manually. Just like pyinstaller/pyinstaller@a11e826.
This is a temporary solution, but it can be solved immediately.
It really works! Super thanks !!!!!
Thank you all for the discussion. Hopefully, the thread can be helpful to others as well.
Hi,
I have followed the above solutions, and the xgboost package can be included by pyinstaller. However, I have found that some python files of xgboost have been added in the dist files. Can I convert these python files to pyd files somehow ?