471,306 Members | 850 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

PyImport_ImportModule("cStringIO") failure with undefinedsymbol

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:
http://groups.google.com/group/comp....bd5f5b15902b14

Thanks in advance for your help.
Regards.

================================================== ============================
Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.credit-suisse.com/legal/e..._email_ib.html
================================================== ============================

Jan 11 '08 #1
1 2528
On Jan 11, 9:31*am, "Borse, Ganesh" <ganesh.bo...@credit-suisse.com>
wrote:
Hi,
Can you please guide me for the following problem?
The call to "PyImport_ImportModule("cStringIO");" is failing with an errorof "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:http://groups.google.com/group/comp....thread/thread/...

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/cStringIO.so"), ld.so does not find
this symbol.
So, as a workaround, we can get the cStringIO.so also linked with the
library which has linked libPython.a.
By this we ensure that PyObject_SelfIter is already resolved in the
library.
Then at the time of importing cStringIO at runtime, this symbol is
already referenced & won't cause problems.
Jan 31 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.