C++调用Python GridSearchCV和joblib报错

我现在使用QT C++调用python的xgboost算法,算法包含了网格搜索gridsearch和模型保存joblib,python算法在pycharm中运行没有错误,但是C++调用的时候会报错。

Python代码段

clf = GridSearchCV(estimator=XGBRegressor(seed=7), param_grid=parameters, cv=5, verbose=1, n_jobs=3)
clf.fit(X_study, y_study)
print("best param" + str(clf.best_params_))
print("best score" + str(clf.best_score_))
print("best estimator" + str(clf.best_estimator_))
#
XGBRegModel = XGBRegressor(**clf.best_params_)
# #这是测试集验证集返回验证效果
X_train, X_test, y_train, y_test = train_test_split(X_study, y_study, test_size=0.1)

XGBRegModel.fit(X_train, y_train)
joblib.dump(XGBRegModel, path)

C++代码段中使用PyObjectCallFunction函数获取值,只要我python文件中包含了gridsearchCV或者joblib这两部分就会报错

Exception ignored in:
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\threading.py", line 1289, in _shutdown
assert tlock.locked()
SystemError: returned a result with an error set

如果去掉单独运行xgboost算法不会报错,请问这是什么原因,我看其他帖子里面说的是线程的问题,但是xgboost算法本身也是多线程,就没有报错,所以我个人还是认为Gridsearch和joblib本身存在着什么特殊情况?

请各位大神指点!

https://blog.csdn.net/a790209714/article/details/56834186