Here are some options for how to inspect and debug Python code:
print
Add print
statements to your code and rerun your program to view the output:
print('any', values, you_want, 'to see')
Python REPL
Instead of running your whole program, start a Python REPL session, and import and run just the portions of your code you want to inspect:
$ python
$ from my_module import my_function
$ my_function()
pdb
See my Pdb notes.
ipdb
- gotcha/ipdb β’ IPython-enabled pdb π οΈ
- Debugging with ipdb - the normal way β’ Muhammad Osama Arshad πΊ
- Debugging with ipdb - the better way β’ Muhammad Osama Arshad πΊ
- Debugging βpytestβ tests with βipdbβ debug mode β’ Michael Mintz πΊ
# use ipdb instead of pdb
$ PYTHONBREAKPOINT=ipdb.set_trace python file.py
pudb
- β¦
# use pudb instead of pdb
$ PYTHONBREAKPOINT=pudb.set_trace python file.py
pdbpp
- pdbpp/pdbpp: pdb++ β’ A drop-in replacement for
pdb
π οΈ
ipython
- IPython Documentation β’ IPython docs π
- 5 Ways of Debugging with IPython β’ Piotr Εwitowski π
jupyter
See my Jupyter notes.
VS Code debugger
Research π
- Python Debug Cheatsheet β’ Peter Xie π
- Debugging Python Like a Boss β’ Zapier π
Inbox
- Online Python Tutor β’ Online Compiler and Visual Debugger for Python, Java, C, C++, and JavaScript π οΈ
- snoop β’ A powerful set of Python debugging tools, based on PySnooper π οΈ
- birdseye β’ Graphical Python debugger which lets you easily view the values of all evaluated expressions π οΈ
- Python Debugging (PyCharm + VS Code) - How to use the PyCharm and VS Code debuggers, and how to use breakpoints and conditional breakpoints to track down where problems are coming from - mCoding