Keep Sharp

Debug Python code using Wingdb

This tip is about using wingide 's debugger to debug your python code. Sometimes the python code can run from terminal but not from wingide ui, it mostly is because the python related environmental variable settings are different when python kernel is start from terminal and from wingide. In this case, you want to start your programe from terminal so it can run properly and still want to be able to debug your code like setting breakpoints, checking stack data. Wingide provide a simple way to achieve this. Basically:

  1. Copy wingdbstub.py from the Wing IDE installation directory into the same directory as your debug program.

  2. At the point where you want debugging to begin, insert following code

import wingdbstub
if 'WINGDB_ACTIVE' in os.environ:
    print "Success starting debug"
else:
    print "Failed to start debug... Continuing without debug"

Comments