Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to debug running Python program using PyCharm debugger

📅 2016-Aug-28 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ debugger, gdb, pdb, pycharm, python ⬩ 📚 Archive

PDB is a fantastic debugger for Python, but it cannot be easily attached to an already running Python program. The recommended method to attach to a running Python program for debugging is GDB as described here. But, examining stack trace of a Python program and Python objects in a C++ debugger like GDB is not straightforward. I recently discovered that the GUI debugger in PyCharm IDE can be used to attach to a running Python program and debug it. It is easy to do this:

$ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

Tried with: PyCharm 2016.2, Python 2.7.11 and Ubuntu 16.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧