---
title: "How to Debug Using ‘pdb’ in Python"
description: "Debugging in Python explained the commands you need. And explained the steps you need to start debug session."
url: https://srinimf.com/2020/08/02/how-to-debug-py-module-using-pdb/
date: 2020-08-02
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2020/08/pexels-photo-4348401.jpeg?fit=1880%2C1258&ssl=1
categories: ["Python"]
tags: ["pdb commands", "pdb tutorial"]
type: post
lang: en
---

# How to Debug Using ‘pdb’ in Python

Here is a topic to use the pdb utility for debugging the python program. Below, you’ll find set and clear the breakpoints set values to variables. A handy list of commands helpful for projects.

**You May Also Like:** [**How to avoid syntax errors in python**](https://www.biganalytics.me/2020/07/python-syntax-errors-fix.html)

## **Step-1: Import pdb package **

See me example Python script – sample.py. Here, you’re importing pdb and debugging.

```
$python -m pdb sample.py
```

## **Step-2: How to use pdb commands at Command-line **

Below is the video that shows the usage of pdb commands at the command-line.

*pdb commands*

## **Handy list: pdb commands**

1. Command to List source code:

- l – it displays 11 lines of source code
- ll – it display entire source codes

2. Command to Set break point:

- b 10 – it sets break point at line 10.

3. Command to Continue:

- c – it continues execution.

4. Command [to debug](https://srinimf.com/2012/06/14/cics-online-xpediter/) line by line:

- s – just executes one line.

5. Command to Execute next line.

- n – it executes next line.

6. Command to Execute up level:

- u 10 – execution up 10 lines.

7. Command to Execute down level:

- d 10 – execution down 10 lines.

9. Command to Quit from debugger:

- q – to quit from debugger.

**References**

- [List of top debugger Commands in Python.](https://docs.python.org/3/library/pdb.html)

## 12 Python Interview Questions

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

[Click to read](https://srinimf.com/2020/02/23/12-frequently-asked-python-interview-questions/)

[CONTACT US](https://srinimf.com/contact-us/)

Related Posts

- [7 Need to Know Python pdb Debugger Commands](https://srinimf.com/2022/03/07/7-need-to-know-python-pdb-debugger-commands/)DateMarch 7, 2022
- [Python Series Vs. Dataframe Top Differences](https://srinimf.com/2020/01/18/python-series-vs-dataframe-explained-top-differences/)DateJanuary 18, 2020
- [12 Tricky Python Coding Interview Questions](https://srinimf.com/2020/02/23/12-frequently-asked-python-interview-questions/)DateFebruary 23, 2020

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2020%2F08%2F02%2Fhow-to-debug-py-module-using-pdb%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2020%2F08%2Fpexels-photo-4348401.jpeg%3Ffit%3D1200%252C803%26ssl%3D1&description=How%20to%20Debug%20Using%20%27pdb%27%20in%20Python)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2020/08/02/how-to-debug-py-module-using-pdb/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2020/08/02/how-to-debug-py-module-using-pdb/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2020/08/02/how-to-debug-py-module-using-pdb/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2020/08/02/how-to-debug-py-module-using-pdb/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20How%20to%20Debug%20Using%20%27pdb%27%20in%20Python&body=https%3A%2F%2Fsrinimf.com%2F2020%2F08%2F02%2Fhow-to-debug-py-module-using-pdb%2F&share=email)
-

### Like this:

Like Loading…
