I'm using embedded Python in C++. I can import a module like so, given my_module.py
is a file:
PyObject* pName PyUnicode_DecodeFSDefault("my_module");
PyObject* pModule = PyImport_Import(pName);
This works nicely for the most part, except that I have no control over where I can put the files containing the module; it has to be in the same directory as the executable. This is a problem for my use-case. I would like to be able to use any path to a file and import the module from there. However, I can seem to find a way to do it.