Embedding Python and command history
Stefan Bellon
sbellon at sbellon.de
Wed Sep 20 08:59:36 EDT 2006
Stefan Bellon wrote:
> int main(void)
> {
> Py_Initialize();
> PyRun_InteractiveLoop(stdin, "<stdin>");
> Py_Finalize();
> }
> How can I make use of command history when embedded Python via
> PyRun_InteractiveLoop?
Sorry to follow up my own posting ...
I found that when I do "import readline" in this simple example, I have
a working command history. When I do this in my real application, then
I get the following:
>>> import readline
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: /usr/lib/python2.4/lib-dynload/readline.so: undefined
symbol: PyExc_IOError
Still experimenting what exactly is causing this.
This application is not linked against libpython. But it loads a shared
object at run time which is linked against libpython and which
contains the call to PyRun_InteractiveLoop. But it looks like this
"plugin" is not enough to make the symbols known to Python. If I add
-lpython2.4 to the linker command when building the main application,
then it works. But this is somewhat against what I was planning to
achieve when using a plugin: independence of the main application from
Python.
Hm.
--
Stefan Bellon
More information about the Python-list
mailing list