Embedded Python (in C) example.

Jason Fritcher jkf at wolfnet.org
Mon Feb 10 07:57:45 CET 2003


jbi130 at yahoo.com wrote in news:873cn3tpry.fsf at syn.codemonkey.net:
> I run the program as in the example but get an error..
> $ ./call multiply 2 2
> ImportError: No module named multiply
> Failed to load "multiply"

First problem I noticed was that they call the program incorrectly... It
should be called like.. 

./call multiply multiply 2 2


Here is what I had to do to make the code work correctly...

Right after Py_Initialize in the C code, I added the following two
lines... 

    PyRun_SimpleString("import sys");
    PyRun_SimpleString("sys.path.insert(0, '')");

The problem was Python wasn't looking for the module in the current
directory.




More information about the Python-list mailing list