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
Visualize Python Code - Python Visualizer, Tutor, and Debugger with AI Help
Free online Python compiler and visual debugger. Step-by-step visualization with AI tutoring to learn data structures and recursion.
Discussions

debugging - How to step through Python code to help debug issues? - Stack Overflow
Python Tutor is an online single-step debugger meant for novices. You can put in code on the edit page then click "Visualize Execution" to start it running. More on stackoverflow.com
🌐 stackoverflow.com
What is best way to learn debugging?
Just practice on my code More on reddit.com
🌐 r/learnpython
59
97
October 8, 2022
Debugging Python programs without an IDE
feedback: use breakpoint() over set_trace, it's available in Python 3.7 and newer consider putting the 2-3 most common/important verbs to the top of the page. I use pp and next and list the most -- they give context, even if they don't know anything else. props for talking about where (I'd forgotten about that one) and up/down <3 I 100% use assert 0, value or breakpoint() inside my unit test. A unit test is basically a high-level specification for what your code should be doing, and is very short, so a good spot for a debugging session. Sometimes I'll do assert/breakpoint inside mainline code I retweeted your link, thanks for posting! More on reddit.com
🌐 r/Python
20
31
April 11, 2022
Learning your IDE Debugger will change your life
Debugging and unit testing is something beginners should learn early on, yet most courses and books barely talk about it. More on reddit.com
🌐 r/learnpython
66
443
August 16, 2021
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 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
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
🌐
Python Tutor
pythontutor.com
Python Tutor - Python Online Compiler with Visual AI Help
Visualize code execution step-by-step. Online compiler and visual debugger for Python, Java, C, C++, and JavaScript. Used by 25+ million people in 180+ countries, and at MIT, Harvard, Berkeley, and 10,000+ schools worldwide.
🌐
Workik
workik.com › ai-powered-python-code-debugger
FREE AI-Powered Python Code Debugger – Debug Python Code Efficiently
AI Proactively scans for and advises on mitigating security vulnerabilities in Python code. ... Sign up to Workik and instantly get started. Set up your Python debugging context with GitHub, GitLab, Bitbucket integration or manually add context such as Django, Flask, Pandas, RESTful APIs, pytest, coding standards, & more for precise support.
🌐
Visual Studio Code
code.visualstudio.com › docs › python › python-web
Run and Debug Python in the Web
November 3, 2021 - The extension comes with an integrated Python REPL. To activate it, run the command Python WASM: Start REPL. There is support for debugging Python files on the Web and it uses the same UI as VS Code Desktop debugging.
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/

Find elsewhere
🌐
Amrdraz
amrdraz.github.io › python-debugger
Python Debugger
An offline ready JavaScript based Python runner and debugger
🌐
Online Python
online-python.com › 1k7INt4ZCl
Online Python - IDE, Editor, Compiler, Interpreter
Online Python IDE is a web-based tool powered by ACE code editor. This tool can be used to learn, build, run, test your python script. You can open the script from your local and continue to build using this IDE. Code and output can be downloaded to local. Code and output can be downloaded to local.
🌐
Hexmos
hexmos.com › freedevtools › c › backend › pdb
Python Debugger (Pdb) - Debug Python Code Online - backend Cheatsheets | Online Free DevTools by Hexmos
November 26, 2025 - Debug Python code online with Python Debugger (Pdb). Step through code, set breakpoints, and inspect variables. Free, fast, and easy to use.
🌐
Ideone
ideone.com › l › python
Online Python compiler and IDE - API provided by Sphere Engine - Ideone.com
Ideone is something more than a pastebin; it's an online compiler and debugging tool which allows to compile and run code online in more than 40 programming languages.
🌐
Pythononlinecompiler
pythononlinecompiler.net
Python Online Compiler - Interpreter & Debugger
... You have to get the environment right to debug Python code with GDB. Here are the steps to get started: sudo apt-get update sudo apt-get install python3-gdb ... GDB online is an online compiler and debugger tool for C/C++ language.
🌐
Domsignal
domsignal.com › home › python online compiler | one-stop solution for code testing and debugging
Python Online Compiler | One-Stop Solution for Code Testing and Debugging
Compile and run Python code online with Domsignal Compiler free tool. No need to install any software; write, test, and debug Python code in your browser.
🌐
Programiz
programiz.com › python-programming › online-compiler
Online Python Compiler (Interpreter) - Programiz
Write and run your Python code using our online compiler. Enjoy additional features like code sharing, dark mode, and support for multiple programming languages.
🌐
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...
🌐
NextLeap
nextleap.app › online-compiler › python-programming
NextLeap - Online Python Compiler
Code, compile, and run Python with NextLeap's fastest python online compiler. Enjoy features like real-time output, code sharing, dark mode, library support, and collaborative coding.
🌐
Python Tutor
pythontutor.com › visualize.html
Visualize code in Python, JavaScript, C, C++, and Java
Free online compiler and visual debugger for Python, Java, C, C++, and JavaScript.
🌐
CodeHS
codehs.com › tutorial › calvin › using-the-python-debugger
Tutorial: Using the Python Debugger | CodeHS
You can also print out the values of each variable at each step of your program. The CodeHS IDE allows you to pause and step through your Python programs by entering "Debug Mode" in your editor settings:
🌐
Codio
codio.com › blog › integrated-debugger-launched-for-multiple-programming-languages
Integrated Online Python debugger and more | Codio
October 20, 2023 - We are very pleased to announce the launch of a brand new code debugging feature within the Codio platform. Our platform now features an online debugger for Python, an online C++ debugger, and debugging tools for Java, C, NodeJS, and PHP..
🌐
Python
wiki.python.org › moin › PythonDebuggingTools
PythonDebuggingTools - Python Wiki
Since debugging is one of the the functions that usually helps make up the "Integrated" in "Integrated Development Environment", expect that most IDEs will have debugging capability even if not listed explicitly here (see IntegratedDevelopmentEnvironments).
🌐
BairesDev
bairesdev.com › home › blog › software development
Best Python Debugging Tools in 2025
Fortunately, there are Python debugging ... efficiently. In this article, we will cover the top Python debugging tools, each with its own unique features and benefits, making it easier for developers to find and fix bugs in their code....