Home » Support » Index of All Documentation » Introduction for New Users » Wing IDE Tutorial » Tutorial: Debugging »

So far we've been debugging code launched from inside of Wing. Wing can also debug processes that are running in a web framework, as scripts in a larger application, or that get launched from the command line.

Let's try this now with example2.py in your tutorial directory. First, copy wingdbstub.py out of your Wing IDE installation directory, which is listed 4th in Wing's About dialog box. Place this in the same directory as example2.py. Next, click on the bug icon in the lower left of Wing IDE's main window and select Accept Debug Connections. Then set a breakpoint on lines 10 and 22 of example2.py:

/images/doc/en/intro/debug-remote.png

If you are working on OS X, using the Windows zip install, or using the Linux tar install of Wing, you will need to edit wingdbstub.py to set WINGHOME to the full path to the Wing IDE installation directory (on OS X, this is the name of Wing's .app directory). This is done automatically by the regular Windows installer and Debian and RPM installs on Linux. If you are using one of those you can skip this step.

Now we're ready to debug example2.py when it is launched from outside of the IDE. To launch it, use the DOS Command prompt on Windows, a bash or similar command prompt on Linux, or Terminal or an xterm on OS X by typing:

python example2.py

You may need to specify the full path to python if it is not on your path.

This should start up the code, print some messages, connect to the IDE, and stop on the breakpoint on line 22. Read through the code and the messages printed to understand what is happening. You can verify that the debugger attached by looking at the color of the bug icon in the lower left of the IDE window, and by hovering the mouse over it:

/images/doc/en/intro/debug-remote-status.png

Once you are stopped at a breakpoint or exception in externally launched code, the debugger works just as it would had you launched the debug process from the IDE. The only difference is that the environment is set up by the process itself and the settings specified in Project Properties and File Properties are not used.

When you continue the debugger from the toolbar or Debug menu, the program should print the value of x and exit.

This is a very simple example to illustrate how externally launched code can be debugged. The import of wingdbstub can also be placed in functions or methods, and there is a debugging API that provides control over starting and stopping debugging.

See Debugging Externally Launched Code for details and the How-To guides for information on setting this up with specific web frameworks, compositing and rendering tools, and other applications.

Remote Debugging

Using the same mechanism, but with some additional configuration, it is also possible to debug Python code running on another machine. This is documented in Remote Debugging in the Wing IDE manual.

« 1.7.3. Tutorial: Execution EnvironmentTable of Contents1.7.5. Tutorial: Other Debugger Features »

Tutorial: Remote Debugging