Reputation: 10575
I have a C++ program which imports a Python module, along the lines of this snippet:
#include <Python.h>
char python_module[] = "my_module";
Py_Initialize();
PyObject* pName;
pName = PyString_FromString(python_module);
pModule = PyImport_Import(pName);
However the module needs to be on the PYTHONPATH
for this line to actually load the module. On Mac or Linux this is relatively straightforward - set PYTHONPATH
on the term you are running the compiled program from. Is there a way to do this for Visual Studio C++? Setting the PYTHONPATH
windows environment variable hasn't helped.
Upvotes: 4
Views: 6709
Reputation: 928
Here is scheme to setup module search path:
You probably need to restart IDE to get it working.
Upvotes: 3