Embedding Python and program path

arve.knudsen at gmail.com arve.knudsen at gmail.com
Thu Jan 15 17:02:03 CET 2009

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
    printf("Program path: %s\n", Py_GetProgramFullPath());

    return 0;

Arve Knudsen

More information about the Python-list mailing list