Embedding Python and program path

A

arve.knudsen

In my application embedding Python I want to have the standard Python
module path, so I try to achieve this by setting the program path to
that of the the interpreter. Even though I call Py_SetProgramName
before Py_InitializeEx, however, Python thinks the program path (as
returned by Py_GetProgramFullPath) is that of my embedding executable.

I would love if someone could explain what is going wrong here, and
eventually provide a better solution for inheriting the Python
interpreter's standard module path.

Test application demonstrating the problem.

#include <Python.h>

int main() {
// Hardcoded for simplicity
Py_SetProgramName("C:\\Python26\\python.exe");
Py_InitializeEx(0);
printf("Program path: %s\n", Py_GetProgramFullPath());
Py_Finalize();

return 0;
}


Thanks,
Arve Knudsen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top