Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use VIM to step debug python like Eclipse and PyDev

Is there a way to use vim to debug python programs and have it look/act somewhat like Eclipse with the PyDev plugin?

What I mean by that is:

  • have it be able to step debug (is that the right term?)
  • see the state all of all variables as the program executes
  • be able to see where in the program the debug process is - maybe line highlighting?

I'm aware that Eclipse is a full featured IDE while VIM is a lightweight generic text editor (and that each comes with its own set of features) but I like being able to work in a console because I have a Windows 7 machine and typically use an Ubuntu Virtualbox to learn and work in python.

I have done some research and found the following things, but none of them seem to do all of what I want to above:

  1. in a python program say import pdb then set a breakpoint in the code. This was line by line and didn't let me see the state of variables
  2. gdb and Clewn. I couldn't get this setup, so if this is my answer just let me know and I'll dig deeper

If I misread the docs on either of the above also let me know and I'll dig back in.

Thanks!

like image 325
Josh R Avatar asked Mar 13 '12 05:03

Josh R


People also ask

How do I debug a Python program in eclipse?

To open the debugger, you need to open the “Debug” perspective. You can do this by selecting “Window → Open Perspective → Other…” from the main menu. In the popup window that appears, select “Debug” and click on the “OK” button. Now, the Eclipse environment changes a little and looks like the one shown in Figure 4.

How do I debug in Pydev?

Now, to debug that file, you can use Shift+F9 (the editor must be focused). NOTE: if you want to re-run the last executed file, you can use F11 to debug it (if you haven't configured F11 to always launch the last launch in debug mode, make sure you read the Getting Started on Running a program).

What is the best way to debug Python?

If you're only interested in debugging a Python script, the simplest way is to select the down-arrow next to the run button on the editor and select Debug Python File in Terminal.


2 Answers

pyclewn is a variation of clewn, which was suggested by user sehe.

From the webpage:

Pyclewn allows using vim as a front end to a debugger. Pyclewn currently supports gdb and pdb.

like image 121
pi. Avatar answered Oct 26 '22 10:10

pi.


My vote is for clewn, allthough I admit I haven't used it for python code. Just C, C++ code, but yes it worked like a charm.

If I remember correctly I even got this working, to a degree, on AIX 5.3 with dbx.

like image 41
sehe Avatar answered Oct 26 '22 10:10

sehe