Questions tagged [pdb]

This tag refers to the Python debugger. For questions pertaining to the protein database file format, use the protein-database tag. For questions pertaining to Microsoft Program Database files, use the pdb-files tag.

The Python Debugger supports breakpoints, single stepping, inspection of stack frames, source code listing, and evaluation of arbitrary Python code in the context of any stack frame. It also supports post-mortem debugging and can be called under program control.

For questions pertaining to the protein database file format (.pdb), use the tag.

For questions pertaining to Microsoft "Program Database" (.pdb) files, use the tag.

880 questions
232
votes
6 answers

How to execute multi-line statements within Python's own debugger (PDB)

So I am running a Python script within which I am calling Python's debugger, PDB by writing: import ipdb; ipdb.set_trace() (iPython's version of PDB, though for the matter I don't think it makes a difference; I use it for the colored output…
Mike
  • 2,321
  • 3
  • 14
  • 3
202
votes
16 answers

Step-by-step debugging with IPython

From what I have read, there are two ways to debug code in Python: With a traditional debugger such as pdb or ipdb. This supports commands such as c for continue, n for step-over, s for step-into etc.), but you don't have direct access to an…
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564
172
votes
9 answers

How to exit pdb and allow program to continue?

I'm using the pdb module to debug a program. I'd like to understand how I can exit pdb and allow the program to continue onward to completion. The program is computationally expensive to run, so I don't want to exit without the script attempting to…
turtle
  • 7,533
  • 18
  • 68
  • 97
146
votes
15 answers

Simpler way to put PDB breakpoints in Python code?

Just a convenience question. I've been a bit spoiled with debuggers in IDEs like Visual Studio and XCode. I find it a bit clumsy to have to type import pdb; pdb.set_trace() to set a breakpoint (I'd rather not import pdb at the top of the file as I…
Joe
  • 46,419
  • 33
  • 155
  • 245
145
votes
11 answers

What is the right way to debug in iPython notebook?

As I know, %debug magic can do debug within one cell. However, I have function calls across multiple cells. For example, In[1]: def fun1(a) def fun2(b) # I want to set a breakpoint for the following line # …
Rex
  • 2,097
  • 5
  • 16
  • 18
128
votes
5 answers

How do I manipulate a variable whose name conflicts with PDB commands?

My code is, for better or worse, rife with single letter variables (it's physics stuff, so those letters are meaningful), as well as NumPy's, which I'm often interacting with. When using the Python debugger, occasionally I'll want to look at the…
Nick T
  • 25,754
  • 12
  • 83
  • 121
114
votes
7 answers

Can I debug with python debugger when using py.test somehow?

I am using py.test for unit testing my python program. I wish to debug my test code with the python debugger the normal way (by which I mean pdb.set_trace() in the code) but I can't make it work. Putting pdb.set_trace() in the code doesn't work…
Joel
  • 3,227
  • 5
  • 21
  • 16
98
votes
5 answers

How do I skip a loop with pdb?

How can I skip over a loop using pdb.set_trace()? For example, pdb.set_trace() for i in range(5): print(i) print('Done!') pdb prompts before the loop. I input a command. All 1-5 values are returned and then I'd like to be prompted with pdb…
Rhys
  • 4,926
  • 14
  • 41
  • 64
91
votes
4 answers

setting breakpoints with nosetests --pdb option

nosetests --pdb let's me halt upon error or failure, but this is too late for my needs. Stepping through code during execution helps me debug where the problem is. However, nosetests are helpful as they allow tests that rely on relative imports…
Devin
  • 2,113
  • 2
  • 22
  • 28
86
votes
2 answers

How to print all variables values when debugging Python with pdb, without specifying each variable?

I'm debugging my Python scripts using pdb and the manual says I can use p variables command to print the values of the specified variables at a certain point. But what if I had lots of variables, like 20 variables, and I would like to track the…
renatov
  • 5,005
  • 6
  • 31
  • 38
84
votes
13 answers

Is it possible to go into ipython from code?

For my debugging needs, pdb is pretty good. However, it would be much cooler (and helpful) if I could go into ipython. Is this thing possible?
Geo
  • 93,257
  • 117
  • 344
  • 520
78
votes
2 answers

Getting started with the Python debugger, pdb

I want to add pdb—the Python debugger—to my toolbox. What's the best way to get started?
Matthew Rankin
  • 457,139
  • 39
  • 126
  • 163
78
votes
4 answers

Docker-compose and pdb

I see that I'm not the first one to ask the question but there was no clear answer to this: How to use pdb with docker-composer in Python development? When you ask uncle Google about django docker you get awesome docker-composer examples and…
McAbra
  • 2,382
  • 2
  • 21
  • 29
76
votes
6 answers

How do you watch a variable in pdb

I'm debugging a python script, and I want to watch a variable for a change (much like you can watch a memory adress in gdb). Is there a way to do this?
Nathaniel Flath
  • 15,477
  • 19
  • 69
  • 94
73
votes
4 answers

Is it possible to step backwards in pdb?

After I hit n to evaluate a line, I want to go back and then hit s to step into that function if it failed. Is this possible? The docs say: j(ump) lineno Set the next line that will be executed. Only available in the bottom-most frame. This lets you…
YPCrumble
  • 26,610
  • 23
  • 107
  • 172
1
2 3
58 59