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
42
votes
9 answers

In the Python debugger pdb, how do you exit interactive mode without terminating the debugging session

Using python 3.5.1 When I run a script using the python debugger module: [home]# python -m pdb myscript.py This starts a debug session: > /somepath/to/myscript.py(1)() -> import os (Pdb) If I want to enter an interactive terminal…
Ray
  • 40,256
  • 21
  • 101
  • 138
41
votes
1 answer

Python debugger tells me value of Numpy array is "*** Newest frame"

What does this mean? My function gets two numpy arrays from a python/c library. After that function call I turn on the debugger to find a bug, so I add the line to look at the two numpy arrays. import pdb; pdb.set_trace() But for the values of…
Framester
  • 33,341
  • 51
  • 130
  • 192
36
votes
6 answers

How to debug a Python module run with python -m from the command line?

I know that a Python script can be debugged from the command line with python -m pdb my_script.py if my_script.py is a script intended to be run with python my_script.py. However, a python module my_module.py should be run with python -m my_module.…
Alexey
  • 3,843
  • 6
  • 30
  • 44
34
votes
4 answers

How to debug python CLI that takes stdin?

I'm trying to debug a Python CLI I wrote that can take its arguments from stdin. A simple test case would have the output of echo "test" | python mytool.py be equivalent to the output of python mytool.py test I'd like to debug some issues with…
whereswalden
  • 4,819
  • 3
  • 27
  • 41
33
votes
3 answers

How to quit ipdb while in post-mortem debugging?

I like to inspect error in a Python script by using: $ python3 -m pdb my_script.py This drops me into a pdb prompt from where I can c continue the execution, and when it hits error, I can inspect the variables and then q quit the script execution…
Ashwin Nanjappa
  • 76,204
  • 83
  • 211
  • 292
31
votes
3 answers

iPython debugger raises `NameError: name ... is not defined`

I can't understand the following exception that is raised in this Python debugger session: (Pdb) p [move for move in move_values if move[0] == max_value] *** NameError: name 'max_value' is not defined (Pdb) [move for move in move_values] [(0.5, (0,…
Bill
  • 10,323
  • 10
  • 62
  • 85
31
votes
3 answers

Interrupt (pause) running Python program in pdb?

In gdb, you can interrupt(pause) the program by C-c and resume. Can you do this in pdb?
eugene
  • 39,839
  • 68
  • 255
  • 489
30
votes
3 answers

How to await a coroutine in pdb

I'm using an async library (asyncpg) and I want to debug some async calls to query the database. I place a pdb breakpoint and want try out a few queries: (pdb) await asyncpg.fetch("select * from foo;") *** SyntaxError: 'await' outside function It…
LondonRob
  • 73,083
  • 37
  • 144
  • 201
29
votes
1 answer

pdb step into a function when already in pdb mode

When in pdb mode I often want to step into a function. Here is a situation that illustrates what I might do. Given the code: def f(x): print('doing important stuff..') result = g(x) + 2 return result def g(x): print('some cool stuff…
morkel
  • 434
  • 1
  • 4
  • 7
29
votes
2 answers

How do you break into the debugger from Python source code?

What do you insert into Python source code to have it break into pdb (when execution gets to that spot)?
Daryl Spitzer
  • 143,156
  • 76
  • 154
  • 173
28
votes
5 answers

PDB won't stop on breakpoint

I'm quite new with debugging directly with pdb and I am having some issues debugging my Django application. Here is what I'm doing: python -m pdb manage.py runserver (pdb) b core/views.py:22 Breakpoint 2 at…
Raphael
  • 7,972
  • 14
  • 62
  • 83
28
votes
2 answers

python: in pdb is it possible to enable a breakpoint only after n hit counts?

In eclipse (and several other IDE's as well) there is an option to turn on the breakpoint only after a certain number of hits. In Python's pdb there is a hit count for breakpoints and there is the condition command. How do I connect them?
zenpoy
  • 19,490
  • 9
  • 60
  • 87
27
votes
5 answers

Launch Python debugger while simultaneously executing module as script

When developing a Python package, it's very convenient to use the -m option to run modules inside the package as scripts for quick testing. For example, for somepackage with module somemodule.py inside it, invoking python -m…
Jed
  • 1,011
  • 1
  • 9
  • 15
27
votes
4 answers

Autocomplete and tab key in PDB

I have been trying to get TAB to do something else than inserting a tab while at the (pdb) prompt. What I have in mind is triggering autocomplete such as in here or here, but the tab key doesn't do anything else than adding tabs to pdb. So…
Rodrigo Lopez
  • 871
  • 10
  • 16
26
votes
3 answers

How do I force Matplotlib to draw while in the ipdb debugger in Spyder (or any other debugger)?

EDIT Unfortunately, at the moment this is not possible. I found out that it is a bug in Spyder. The developers are still figuring out how to approach this. Goal Visualize data while debugging code (and I want to use Spyder too!). Attempt #1: Run…
Peter D
  • 3,283
  • 4
  • 24
  • 23
1 2
3
58 59