Debugging Python Applications
Debugging is the process of examining your application for errors.
The process of debugging is accomplished by setting breakpoints and
watches in your code and running it in the debugger.
This enables you to execute your code one line at a time and examine
the state of your application in order to discover any problems.
Setting Up Python Projects for Debugging
- Check Debugger options: Go to Tools > Options > Python and
click on the Debugger tab :
- Debugger listening starting port: For better
isolation when debugging, the debugger is automatically started in a separate
process and communicates with the IDE over an IP socket.
This field specifies the port number where the debugger process
is listening for incoming Python debugging solicitations.
- Debugging shell colors and fonts:This group of buttons customizes
the debugging shell colors.
- Stop at first line: When checked, the debugger will stop at the
first line of the debugger script. When unchecked the debugger will stop at
the first breakpoint found in the script.
- Setting the breakpoints: In the Source Editor, click in the left
margin next to the desired line of code where you want to set a breakpoint.
Starting the Debugger
After the breakpoints have been set, click on Debug and select the appropriate option to start the debugging session.
- If there is more than one project open, Ctrl + F5 will start the debugging session on the main project.
- To start a debugging session on a particular Python file, select the file and type Ctrl + Shift + F5.
Debugger Windows
In addition to the Default Shell window, there are windows which display
other runtime configurations of the application currently being debugged:
- Call Stack Window
- Local Variables Window
- Threads Window
- See also
- Python Project Tasks: Quick Reference
Legal Notices