Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用xgboost使用pyinstaller创建.exe,代码为_Python_Pyinstaller_Xgboost - Fatal编程技术网

Python 如何使用xgboost使用pyinstaller创建.exe,代码为

Python 如何使用xgboost使用pyinstaller创建.exe,代码为,python,pyinstaller,xgboost,Python,Pyinstaller,Xgboost,我使用的是python 3.6.4和pyinstaller 3.4。 我的代码导入numpy和xgboost。 我希望从项目中创建一个.exe 下面的代码作为.py运行,在我的机器上没有任何问题 import xgboost as xgb import numpy as np init() data = np.random.rand(5,10) # 5 entities, each contains 10 features label = np.random.randint(2, siz

我使用的是python 3.6.4和pyinstaller 3.4。 我的代码导入numpy和xgboost。 我希望从项目中创建一个.exe

下面的代码作为.py运行,在我的机器上没有任何问题


import xgboost as xgb

import numpy as np

init()

data = np.random.rand(5,10) # 5 entities, each contains 10 features
label = np.random.randint(2, size=5) # binary target
dtrain = xgb.DMatrix( data, label=label)

dtest = dtrain

param = {'bst:max_depth':2, 'bst:eta':1, 'silent':1, 'objective':'binary:logistic' }
param['nthread'] = 4
param['eval_metric'] = 'auc'

evallist  = [(dtest,'eval'), (dtrain,'train')]

num_round = 10
bst = xgb.train( param, dtrain, num_round, evallist )

bst.dump_model('dump.raw.txt')
当我转换为exe时

并将以下内容写入.spec文件: exe正在成功创建

但是,当我运行.exe文件时,会出现以下屏幕:

PyInstaller cannot check for assembly dependencies.
Please install PyWin32 or pywin32-ctypes.

pip install pypiwin32
任何情况下,我都需要安装pypiwin32

如果有人知道如何解决这个问题,你会很感激吗?研究后:

要使用pyinstaller从使用xgboost库的脚本生成exe,请执行以下操作:

1.必须首先获取xgboost.dll并将其插入dist folder-link中的文件夹名xgboost中:[

请使用下面的代码获取隐藏的导入,在xgboost情况下所需的数据和二进制文件应为空 从PyInstaller.utils.hooks导入collect\u all 数据、二进制文件、hiddenimports=collect_allxgboost 并将其添加到.spec文件中。 祝你好运

PyInstaller cannot check for assembly dependencies.
Please install PyWin32 or pywin32-ctypes.

pip install pypiwin32