How to debug using pdb in python

Here is python ‘pdb’ debugging utility for python programs. Here is pdb tutorial on how to debug .py module at command level interface (CLI).

Here is how to set break point and how to clear them. Also, in the below, I have listed useful pdb commands.

You May Also like: How to avoid syntax errors in python.


  1. Install ‘pdb’ package in your Python interpreter
  2. The usage of ‘pdb’ explained in Video
  3. Top pdb commands
Photo by RODNAE Productions on

1. Install ‘pdb’ package.

My python script is Here, you are importing pdb and executing the debug.

$python import pdb
$python -m pdb

2. How to use ‘pdb’ utility.

How to debug .py module using pdb in Python

3. Python pdb commands to debug

List source code:

l – it displays 11 lines of source code

ll – it display entire source codes

Set break-point:

b 10 – it sets break point at line 10.


c – it continues execution.

Debug line by line:

s – just executes one line.

Execute next line.

n – it executes next line.

Execute up level:

u 10 – execution up 10 lines.

Execute down level:

d 10 – execution down 10 lines.

Quit from debugger:

q – to quit from debugger.


12 Python Top Interview Questions

These questions useful for your next interview and to use in your project.

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.