PyImport_ImportModule("cStringIO") failure with undefined symbol

grbgooglefan ganeshborse at
Thu Jan 31 11:49:29 CET 2008

On Jan 11, 9:31 am, "Borse, Ganesh" < at>
> Hi,
> Can you please guide me for the following problem?
> The call to "PyImport_ImportModule("cStringIO");" is failing with an error of "undefined symbol:PyObject_SelfIter".
> Before importing this module, I am importing only the sys module.
>    Py_SetProgramName("/usr/bin/python");
>    Py_Initialize();
>    char* argv[] = { "python","-v",""};
>    PySys_SetArgv(2,argv);
>    PyRun_SimpleString("import sys");
>    PyObject *modStringIO = NULL;
>    // Import cStringIO module
>    modStringIO = PyImport_ImportModule("cStringIO");
> Should I be importing any other additional module(s) to make this import work?
> Please help.
> I am trying to use the function GetPythonErrorMessage provided in this post:
> Thanks in advance for your help.
> Regards.

Function "PyObject_SelfIter" is part of libPython.a. But when library
which is linked with libPython.a tries to import cStringIO (which is
nothing but dlopen("lib-dynload/"), does not find
this symbol.
So, as a workaround, we can get the also linked with the
library which has linked libPython.a.
By this we ensure that PyObject_SelfIter is already resolved in the
Then at the time of importing cStringIO at runtime, this symbol is
already referenced & won't cause problems.

More information about the Python-list mailing list