PyDev: How to call a debug command from the console (with breakpoints)?

Suppose I wrote a function that I want to debug.

PyDev helps debug a lot with its advanced features, such as breakpoints.

After setting breakpoints, one of the debugging methods is to write a function call in def main() or only in the module body and press the button enter image description here .

Is it possible to start a debugging session of a function along with its arguments from the console? (Same as in RStudio or VBA ...)


This question is a duplicate of pydev: debugging in console mode (interactive)?


Update: I really don't know what the magic combination of clicks are that makes interactive debugging possible.

Here is what I am doing that does not work (on Ubuntu 14.04 and Eclipse 4.4.I20140606-1215 with PyDev 3.6.0.2014062323, Python 3.4.0, IPython 1.2.1)

First try:

First I create a new PyDev project: enter image description here

Then I insert a new .py file with some code and create some breakpoints: enter image description here

Then I right click on the code, Debug As... Python run .

And then 2 consoles open, none of them are IPython. The active console is called [Debug console] proba.py . [Debug console] proba.py Typing commands in this console does not force the computer to execute them.

Another console is available, simply called proba.py . <code> proba.py </code> console This console is fully interactive, although it is not IPython.

This is a truly interactive debugger. You can go through the code and check the variables. Unfortunately, updating variables is not supported; if I enter the command a=10 , the variable will not be updated.

Second attempt

This time, try starting IPython before starting a debugging session. After Ctrl + Alt + Enter, I select Console for currently active editor :

enter image description here

Then Python3 (because this is what I need): enter image description here

After that, I have a fully working IPython console. Ipython console

When I run the file through execfile , it raises the error Failed to create input stream: Read timed out : enter image description here

Although the code seems to be working, I cannot access the variables from the IPython console, although I can access them from the Variables view: enter image description here

+6
python debugging ipython pydev
source share
1 answer

In fact, yes, you can do this in the latest versions of PyDev.

You must enable this in the settings as described in:

http://pydev.org/manual_adv_interactive_console.html#full-debug-support-in-interactive-console

(i.e.: connect the console to a debugging session)


Change (applies to the 2nd part):

Unfortunately, as it should be, this is expected ... your code is “locked” at the breakpoint, and thus the console cannot respond to you and make no assessment while you are at the breakpoint in this mode ( you can only use the clock / debugger expressions at this point), so the idea is that you use the console to perform tasks, and then you can add a breakpoint if you want, but you can use the console again when you leave the point breakdown.

Note: if you want to use the interactive console in the context of a breakpoint, another approach would be to select the stack frame (in debug mode) by right-clicking it> pydev> Debug Console (or you can also create a new console view in the debug view to a debugging session for the same effect).

+3
source share

All Articles