[IPython-user] Exception embedding IPython - help please

Fernando Perez Fernando.Perez at colorado.edu
Fri Oct 14 15:58:27 CDT 2005

brucedickey at micron.com wrote:

> Python 2.3.4
> IPython 0.6.15 for Python 2.3 from the src rpm
> Embedding in a wxPython app, wxPython
> First time user.
> My code:
> import IPython
> from IPython.Shell import IPShellEmbed
> args = ['-pdb', '-pprint', '-debug', '-colors', 'Linux']
> ipshell = IPShellEmbed(args, banner = 'Entering IPython', exit_msg =
> 'Going back to main program')
> ipshell("Here we go")
> print 'Back in main program'
> An exception is generated in shell.py ln 705 in fixLineEndings(): lines
> = text.split('\r\n'),
> from write(): text = self.fixLineEndings(text),
> from raw_input(): write(prompt).
> Well, prompt is a prompt object, not a string, so split() naturally does
> not work on it.
> Please tell me how to get around this.

Please post an actual traceback, not a paraphrase thereof.  Without a real 
traceback, I don't know what code to actually look at.  There is no 
fixLineEndings method anywhere in ipython, for one thing.

> Secondly, I would like to have the IPython shell available all the time
> in a wxPython window w/o it being an either/or situation (run my
> wxPython app or IPython but not both at once). I.e. Have a notebook
> control with tabs for my app's functionality and a tab for IPython so
> the user can select any tab and use what is on it at any time. Any way
> to do this? The IPython doc made it look like the app its embedded in is
> suspended while in ipshell()....

It's possible, but there is no 'out of the box' prepackaged class to do this, 
like there is for blocking embedding.  You'll have to finagle something using 
the threaded classes in Shell.py (specifically, the one for WX).  I know it's 
possible in principle, because the BrainVISA team did precisely that, but in a 
Qt context.  You may also try to download their code for inspiration (the 
basic ideas are probably similar):


I didn't directly work on that, so I'm not familiar with the details, nor do I 
know whether this functionality is in already released code or only in CVS. 
You may want to send an email to their forum 
(http://brainvisa.info/contact.html) to find out.



More information about the IPython-user mailing list