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 ipdb
s interact
to give me the fully featured IPython
console?
You start IPython by typing “ipython” in your terminal. $ ipython Python 2.7.
The ease of use of Python and its dynamic nature make it a very productive language. IPython is an interactive command-line terminal for Python. It was created by Fernando Perez in 2001. IPython offers an enhanced read-eval-print loop (REPL) environment particularly well adapted to scientific computing.
The IPython Console allows you to execute commands and interact with data inside IPython interpreters. To launch a new IPython instance, go to New console (default settings) under the Consoles menu, or use the keyboard shortcut Ctrl - T ( Cmd - T on macOS) when the console is focused.
You can use run command in the input prompt to run a Python script. The run command is actually line magic command and should actually be written as %run. However, the %automagic mode is always on by default, so you can omit this.
In .pdbrc
:
import IPython
[..]
# Interactive shell
alias interacti IPython.embed()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With