Hi,
When I run the code below, I manage to execute certain python code but not some
simple imports.
For example, the code below... (I removed some error checking/reference checks
for brevity)
// ...
Py_SetProgramName(L"AAAAA");
Py_SetPath(L"path\\to\\python35.zip"); // embeddable from the python site.
Py_Initialize();
PyThreadState *mainstate = PyThreadState_Get();
PyInterpreterState* mainInterpreterState = mainstate->interp;
PyObject *main_module = PyImport_AddModule("__main__");
PyObject *main_dict = PyModule_GetDict(main_module);
PyObject *local_dic = PyDict_New();
const char* s = "import ctypes\n";
PyObject * PyRes = PyRun_String(s, Py_file_input, main_dict, local_dic);
PyObject* ex = PyErr_Occurred();
if (NULL != ex)
{
// didn't work, import error.
}
// cleanup...
// ...
I can do some imports, ("import sys" for example), but most of the others do
not work, "import ctypes" for example.
Any suggestions as to what I might be missing?
S.
--
https://mail.python.org/mailman/listinfo/python-list