embedded python example: PyString_FromString doesnt work?
Denis S. Otkidach
ods at strana.ru
Fri Mar 25 03:09:35 EST 2005
On Thu, 24 Mar 2005 21:12:18 +0000 David Harris wrote:
DH> int
DH> main(int argc, char *argv[])
DH> {
DH> PyObject *pName, *s, *pModule, *pDict, *pFunc;
DH> PyObject *pArgs, *pValue;
DH> int i;
DH>
DH> if (argc < 3) {
DH> fprintf(stderr,"Usage: call pythonfile funcname [args]\n");
DH> return 1;
DH> }
DH>
DH>
DH> Py_Initialize();
[...]
DH> Calling the program gives an error;
DH> "david at palmer:~/source/python> ./test_String script1.py multiply 4
DH> 5 import went bang...
DH> ImportError: No module named script1.py"
DH> script1.py exists and it is in the same directory as the executable
DH> so its not a path error or that kind of stuff.
I believe you have to call Py_SetProgramName before Py_Initialize, or
otherwise let Python know that it should look for modules in this
directory. See http://python.org/doc/current/api/embedding.html#l2h-40
--
Denis S. Otkidach
http://www.python.ru/ [ru]
More information about the Python-list
mailing list