Embedding Python in C
Michael P. Reilly
arcege at shore.net
Thu Jul 15 17:36:58 EDT 1999
In comp.lang.python Thomas R*berg <thomar at ifi.ntnu.no> wrote:
: I am writing a program in C/C++ and want to embed Python. The one problem I
: encounter is that when I try to import a module using
: Pyrun_SimpleString("import mymodule\n"), this module is not found. I have
: specified the correct paths at the correct places in my Makefile (at least I
: think I have). Anyone had problem with this??
It might be that the sys.path is not set correctly in the C program
before calling the PyRun_SimpleString() function. Did you insert your
library directory into the path before attempting to import your module?
PyRun_SimpleString("from sys import path; path.insert(0, 'Mydir')");
-Arcege
More information about the Python-list
mailing list