Dear EDEM Support Team,
I am currently developing a C++ plugin for EDEM and would like to call custom Python functions using the Python C API (e.g., PyImport_ImportModule, PyObject_CallObject, etc.).
These Python scripts work correctly in a standalone Python environment, and calling the Python modules from a standalone C++ application also works without issues.
If I call Py_Initialize() or PyEval_InitThreads() from the plugin, EDEM sometimes crashes with the message:(Fatal Python error: can't initialize sys standard streams).
I have already tried:
1. Using EDEM's built-in Python38.dll and python38.lib;
2. Using my locally installed official Python 3.8 interpreter;
3. Using GIL management;
However, both environments result in the same random crash, especially during the second call to Python.
My questions are:
1. Does EDEM internally initialize and manage a Python interpreter via Python C API?
2. Is it supported and safe to use the Python C API from within a plugin (e.g., Py_Initialize, PyGILState_Ensure)?(Particle Body Force)
3. If so, is there a recommended initialization order, thread management, or plugin calling procedure?
4. Is there a recommended way to safely interact with EDEM’s Python environment from a C++ plugin?
Any advice, recommended practices, or documentation references would be greatly appreciated.
Thank you very much for your support and assistance!