Make 'interact' use IPython console, rather than standard Python one?
Asked Answered
S

1

8

In pdb/ipdb debugging, the useful interact command gives me a fully featured interactive Python console.

However, this appears to always be the "standard" Python console, even if I use ipdb to begin with. Is there a way to configure ipdb such that interact will give me the IPython console, rather than the standard Python one? Interestingly, I do get the IPython style prompt, but I don't get to use IPython magic such as %whos:

In [24]: 1/0
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-24-05c9758a9c21> in <module>()
----> 1 1/0

ZeroDivisionError: division by zero

In [25]: %debug
> <ipython-input-24-05c9758a9c21>(1)<module>()
----> 1 1/0

ipdb> interact
*interactive*
In : %whos
  File "<console>", line 1
    %whos
    ^
SyntaxError: invalid syntax

Is there a way to get ipdbs interact to give me the fully featured IPython console?

Sender answered 19/8, 2014 at 23:8 Comment(4)
Did my solution work for you?Demon
@Demon Only on the first iteration! See edit.Sender
What if you exit (control+d) from ipdb after %debug?Demon
@Demon Hmm, I tried again and I cannot fully reproduce the problem I noticed yesterday. Not sure what was going on, but it works now.Sender
D
7

In .pdbrc:

import IPython 
[..]
# Interactive shell
alias interacti IPython.embed()
Demon answered 17/7, 2015 at 11:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.