我的python腳本中只要使用到了其他第三方庫 numpy 等其它庫,PyImport_ImportModule就會失敗,如果不匯入這些庫就能成功
參考別人的教程https://blog.csdn.net/m0_38125278/article/details/87191971還是沒用
{
Py_SetPythonHome(L"D:/Python/Python36.8");
Py_Initialize();//加載Python解釋器
if (!Py_IsInitialized()){
//printf("Python envirment initialized successfully!");
return 0;
}
PyRun_SimpleString("import sys");
PyRun_SimpleString("sys.path.append('./')");
//PyRun_SimpleString("sys.path.append('D:/Python/Python36.8/Lib')");
PyObject * pModule = NULL;
PyObject * pFunc = NULL;
PyObject *pArgs = NULL;
PyObject *pResult = NULL;
pModule = PyImport_ImportModule("test");//Python py檔案名
Py_Finalize();//卸載Python解釋器
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/61576.html
標籤:其它技術問題
