Yes! There's a Python debugger called pdb just for doing that!

You can launch a Python program through pdb via python -m pdb myscript.py.

There are a few commands you can then issue, which are documented on the pdb page.

Some useful ones to remember are:

  • b: set a breakpoint
  • c: continue debugging until you hit a breakpoint
  • s: step through the code
  • n: to go to next line of code
  • l: list source code for the current file (default: 11 lines including the line being executed)
  • u: navigate up a stack frame
  • d: navigate down a stack frame
  • p: to print the value of an expression in the current context

If you don't want to use a command line debugger, some IDEs like Pydev, Wing IDE or PyCharm have a GUI debugger. Wing and PyCharm are commercial products, but Wing has a free "Personal" edition, and PyCharm has a free community edition.

Answer from user193476 on Stack Overflow
🌐
OnlineGDB
onlinegdb.com › online_python_debugger
Online Python Debugger - online editor
''' Online Python Debugger. Code, Run and Debug Python program online. Write your code in this editor and press "Debug" button to debug program.
🌐
Python Tutor
pythontutor.com › python-compiler.html
Online Python Compiler, Visual Debugger, and AI Tutor
Online Python compiler with AI help - the only tool that lets you visually debug your code step-by-step and get AI to help you (also debug JavaScript, Java, C, and C++ code)
Discussions

Does anyone use python debugger?
I use PyCharm and always use the debugger. More on reddit.com
🌐 r/Python
110
67
March 12, 2022
Debugging Plone with VS Code and Python 2.7 - Plone Support - Plone Community
Hi everyone, I'm new to Plone and still learning Python, so please forgive me if I ask any basic question. I'm trying to debug code using VS Code, and everything works fine until the server starts in a new process via a subprocess.call() command. I can set breakpoints in bin/initialize, but ... More on community.plone.org
🌐 community.plone.org
0
August 14, 2024
Learn how to use the debugger
print("HERE") print("INSIDE LOOP") Never quittinh this. More on reddit.com
🌐 r/learnpython
39
147
December 12, 2024
What is best way to learn debugging?
Just practice on my code More on reddit.com
🌐 r/learnpython
59
97
October 15, 2022
People also ask

What is Python Code Debugging?
Python code debugging is the process of identifying and resolving errors or bugs in Python code. Debugging involves identifying and fixing errors, analyzing performance, and ensuring code reliability to understand why it is not working as expected and making corrections to ensure it performs correctly.
🌐
workik.com
workik.com › ai-powered-python-code-debugger
FREE AI-Powered Python Code Debugger – Debug Python Code Efficiently
What are popular use-cases of Python Code Debugging?
Popular use cases of Python Code Debugging include: 1. Runtime Error Detection: Identify and fix errors that occur during Python code execution. 2. Performance Profiling: Analyze and improve the performance of the python code. 3. Unit Testing: Verify the functionality of individual Python components. 4. Memory Management: Track and optimize memory usage. 5. Code Flow Analysis: Understand and visualize the flow of Python code execution.
🌐
workik.com
workik.com › ai-powered-python-code-debugger
FREE AI-Powered Python Code Debugger – Debug Python Code Efficiently
What are the popular Python debugger use cases?
Popular use cases include but are not limited to: 1. Debugging web development issues in Django and Flask. 2. Identifying and optimizing data science errors with NumPy, pandas, Matplotlib. 3. Enhancing IoT project performance by debugging asynchronous code. 4. Improving machine learning models and data preprocessing in TensorFlow or PyTorch. 5. Streamlining the upgrade of legacy Python systems to newer versions.
🌐
workik.com
workik.com › ai-powered-python-code-debugger
FREE AI-Powered Python Code Debugger – Debug Python Code Efficiently
Top answer
1 of 15
409

Yes! There's a Python debugger called pdb just for doing that!

You can launch a Python program through pdb via python -m pdb myscript.py.

There are a few commands you can then issue, which are documented on the pdb page.

Some useful ones to remember are:

  • b: set a breakpoint
  • c: continue debugging until you hit a breakpoint
  • s: step through the code
  • n: to go to next line of code
  • l: list source code for the current file (default: 11 lines including the line being executed)
  • u: navigate up a stack frame
  • d: navigate down a stack frame
  • p: to print the value of an expression in the current context

If you don't want to use a command line debugger, some IDEs like Pydev, Wing IDE or PyCharm have a GUI debugger. Wing and PyCharm are commercial products, but Wing has a free "Personal" edition, and PyCharm has a free community edition.

2 of 15
87

By using Python Interactive Debugger 'pdb'

First step is to make the Python interpreter enter into the debugging mode.

A. From the Command Line

Most straight forward way, running from command line, of python interpreter

$ python -m pdb scriptName.py
> .../pdb_script.py(7)<module>()
-> """
(Pdb)

B. Within the Interpreter

While developing early versions of modules and to experiment it more iteratively.

$ python
Python 2.7 (r27:82508, Jul  3 2010, 21:12:11)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pdb_script
>>> import pdb
>>> pdb.run('pdb_script.MyObj(5).go()')
> <string>(1)<module>()
(Pdb)

C. From Within Your Program

For a big project and long-running module, can start the debugging from inside the program using import pdb and set_trace() like this:

#!/usr/bin/env python
# encoding: utf-8
#

import pdb

class MyObj(object):
    count = 5
    def __init__(self):
        self.count= 9

    def go(self):
        for i in range(self.count):
            pdb.set_trace()
            print i
        return

if __name__ == '__main__':
    MyObj(5).go()

Step-by-Step debugging to go into more internal

  1. Execute the next statement… with “n” (next)

  2. Repeating the last debugging command… with ENTER

  3. Quitting it all… with “q” (quit)

  4. Printing the value of variables… with “p” (print)

    a) p a

  5. Turning off the (Pdb) prompt… with “c” (continue)

  6. Seeing where you are… with “l” (list)

  7. Stepping into subroutines… with “s” (step into)

  8. Continuing… but just to the end of the current subroutine… with “r” (return)

  9. Assign a new value

    a) !b = "B"

  10. Set a breakpoint

    a) break linenumber

    b) break functionname

    c) break filename:linenumber

  11. Temporary breakpoint

    a) tbreak linenumber

  12. Conditional breakpoint

    a) break linenumber, condition

Note: All these commands should be executed from pdb

For in-depth knowledge, refer:

  • https://pymotw.com/2/pdb/

  • https://pythonconquerstheuniverse.wordpress.com/2009/09/10/debugging-in-python/

🌐
Visual Studio Code
code.visualstudio.com › docs › python › debugging
Python debugging in VS Code
November 3, 2021 - The Python extension supports debugging through the Python Debugger extension for several types of Python applications. For a short walkthrough of basic debugging, see Tutorial - Configure and run the debugger. Also see the Flask tutorial. Both tutorials demonstrate core skills like setting breakpoints and stepping through code.
Find elsewhere
🌐
Workik
workik.com › ai-powered-python-code-debugger
FREE AI-Powered Python Code Debugger – Debug Python Code Efficiently
Input context — libraries, APIs, frameworks, DB schemas, & more — into Workik AI for tailored debugging. ... AI Accurately identifies and resolves syntax, runtime, and logic errors in Python for refined code.
🌐
Python
docs.python.org › 3 › library › pdb.html
pdb — The Python Debugger
Source code: Lib/pdb.py The module pdb defines an interactive source code debugger for Python programs. It supports setting (conditional) breakpoints and single stepping at the source line level, i...
🌐
Code With Mu
codewith.mu › en › tutorials › 1.2 › debugger
The Visual Debugger
It’s a useful ability because you get to compare how you think your code is run with how Python actually runs it. This is extraordinarily helpful if you’re trying to find bugs. This is what Mu’s simple visual debugger allows you to do with Python 3 code.
🌐
Medium
medium.com › @yellalena › a-guide-to-debugging-python-code-and-why-you-should-learn-it-ae30d20419b7
A Guide to Debugging Python code (and why you should learn it) | by Aliona Matveeva | Medium
August 15, 2023 - Why is it None then? We could continue playing a guessing game, but this is actually the perfect moment to start debugging. Python provides you with an awesome built-in code debugger: the pdb module.
🌐
CodeHS
codehs.com › tutorial › calvin › using-the-python-debugger
Tutorial: Using the Python Debugger | CodeHS
CodeHS is using the industry standard built-in Python debugger, PDB, to pause and step through your Python programs.
🌐
ArcGIS Pro
pro.arcgis.com › en › pro-app › 3.4 › arcpy › get-started › debugging-python-code.htm
Debug Python code—ArcGIS Pro | Documentation
Start Microsoft Visual Studio and open the script to be debugged. On the main menu, click Debug > Attach to Process. On the Attach to Process dialog box, click the Select button. On the Select Code Type dialog box, check Debug these code types, check Python, and click OK.
🌐
JetBrains
jetbrains.com › help › pycharm › part-1-debugging-python-code.html
Part 1. Debugging Python Code | PyCharm Documentation
By the way, you can enter Python commands in the Debug Console when the program is suspended: On the stepping toolbar of the Debugger tab, click the (Resume Program) button to move to the next breakpoint. In the editor, you can see text in italics next to the lines of code:
🌐
Plone Community
community.plone.org › plone support
Debugging Plone with VS Code and Python 2.7 - Plone Support - Plone Community
August 14, 2024 - Hi everyone, I'm new to Plone and still learning Python, so please forgive me if I ask any basic question. I'm trying to debug code using VS Code, and everything works fine until the server starts in a new process via a subprocess.call() command. I can set breakpoints in bin/initialize, but ...
🌐
BairesDev
bairesdev.com › home › blog › software development
Best Python Debugging Tools in 2025
A debugger allows developers to pause the execution of their code and inspect variables, expressions, and the program’s state at any given point. This makes it easier to isolate the source of an error and understand how the code is behaving. Using a Python debugger has its share of benefits, including:
🌐
Microsoft Learn
learn.microsoft.com › en-us › visualstudio › python › debugging-python-in-visual-studio
Debug Python code, set breakpoints, inspect code - Visual Studio (Windows) | Microsoft Learn
To debug code in a standalone Python file, open your file in Visual Studio, and select Debug > Start Debugging. Visual Studio launches the script with the global default environment and no arguments.
🌐
Codersarts
codersarts.com › post › building-a-python-code-debugger-with-openai-a-step-by-step-tutorial
Building a Python Code Debugger with OpenAI: A Step-by-Step Tutorial
August 13, 2024 - The Python Code Debugger is designed to help developers identify and fix errors in their Python code. By inputting code snippets, the debugger uses OpenAI's GPT-3.5-turbo model to analyze the code and provide suggestions for corrections.
🌐
Real Python
realpython.com › debug-python-errors
How to Debug Common Python Errors – Real Python
July 14, 2025 - Python debugging involves identifying and fixing errors in your code using tools like tracebacks, print() calls, breakpoints, and tests. In this tutorial, you’ll learn how to interpret error messages, use print() to track variable values, ...
🌐
Hexmos
hexmos.com › freedevtools › c › backend › pdb
Python Debugger (Pdb) - Debug Python Code Online - backend Cheatsheets | Online Free DevTools by Hexmos
November 26, 2025 - The Python Debugger (Pdb) is a powerful tool for debugging Python code. It allows you to step through your code line by line, inspect variables, and set breakpoints to understand the flow of execution and identify errors.
🌐
Reddit
reddit.com › r/learnpython › learn how to use the debugger
r/learnpython on Reddit: Learn how to use the debugger
December 12, 2024 -

I know a lot of you out there who are just getting started in python are probably using print statements to debug. While this is an easy way to debug your code there’s a lot of drawbacks when comparing it to debuggers especially in professional environments. Python has its own debugger package called pdb which uses the command line. I prefer the interactive debugger in vscode but every IDE has a debugger.

A debugger will let you mark points in code where you want to examine things further called break points. When the code reaches a break point in the debugger it will pause there allowing you to see details like variable values at that point in execution. From here you can run the code line by line as well as “step into” or out of functions. There’s also a python repl which lets you run code using all of the variables available at the breakpoint; this lets you test out different bits of code without needing to rerun everything.

If you’re still wondering why a debugger can be better than print statements in professional environments then here’s why:

  • You should not be committing any code with print statements. Anything that needs to be outputted to stdout should be with the logger.

  • Some code can take a while to run so if you’re using a debugger you don’t have to run it multiple times to test out different snippets.

  • In large code bases it can be difficult to trace things through; add to that layers of abstraction from object oriented programming and it can be hard sometimes to keep up. Using the debugger helps you understand what’s happening line by line.

🌐
CodeChef
codechef.com › python-online-compiler
Online Python Compiler and Visualizer
Welcome to our AI-powered online Python compiler and interpreter, the perfect platform to run and test your Python code efficiently. Our tool makes coding easy for developers of any skill level, whether you're a beginner or experienced.