By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,908 Members | 2,055 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,908 IT Pros & Developers. It's quick & easy.

PyImport_ImportModule("cStringIO") failure with undefinedsymbol

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.