The Canopy editor includes a Python GUI debugger, which is available to Canopy users who have logged in from the Canopy Welcome Screen.
The Canopy debugger is tightly integrated with IPython’s debugger, and adds GUI tools for stepping through code and setting breakpoints.
It also provides a variable browser, which makes it quick and easy to inspect variables in the current Python namespace, including complex objects such as NumPy arrays.
Enabling access to the debugger
The Canopy debugger is available all Canopy users who have logged into Canopy on the Welcome Screen. To authenticate your debugger access initially, you may need to log in again or restart Canopy while net-connected. If you subsequently go offline, you can continue using the debugger.
If you access the internet through a proxy firewall, you will need to explicitly configure your proxy in Canopy's preferences dialog. For more details, see "Can I use Canopy Behind a Proxy Firewall?".
For commercial subscribers who can never gain access to the Canopy servers online (typically on machines which are disconnected, or are behind a stringent firewall or a proxy not yet supported by Canopy), please contact us at support@enthought.com for manual activation credentials.
To verify that your debugger has been activated, open a Python source file in the Canopy editor and check that the debugger toolbar is visible.
Resources for learning to use the debugger
- "Canopy Debugger Guide" (also available offline in the Canopy Help menu’s Documentation Browser).
- Video introduction to common debugger usage scenarios:
FAQs
- "Step Over" - The name of this action can be confusing at first. Perhaps it would better have be named "Step flat" or "Step at this level" or simply "Step", but for better or worse, "Step Over" is the name that is now pervasive in the software industry. "Step Over" does not ignore or skip the next statement. Rather, it executes the next statement as a whole, rather than stepping into the implementation of that statement (e.g. into a called function). It then stops at the next statement at the same level.
- "Step Into" an import statement - It may appear that the debugger does not single-step into import statements. Actually, this appearance happens because if a module has already been imported, then the import statement reduces to an assignment (adding a reference, in the current module namespace, to that already existing imported module object). So there's nothing to single-step into.
Known issues with the debugger
Since Canopy is at end of life (as of Canopy version 2.1.9), none of these issues will be fixed.
Auto-debug
- Auto-debug (the toolbar icon that looks like a red filled-in circle surrounded by rings of white and black) should normally be disabled. It can interfere with normal debugging, including causing freezes.
- Auto-debug can also interfere with normal kernel running. For example, it can sometimes prevent a command being executed when the "Enter" key is pressed in the Canopy Python shell.
- Auto-debug can debug at breakpoints, but not at exceptions.
- When auto-debug mode is on, all ipython magic commands must begin with "%" (otherwise they are not recognized as magic commands).
- For more about auto-debugging, see Debugger Toolbar.
Breakpoints
- The debugger allows you to set a breakpoint on a "pass" statement, but is not consistent about whether it will stop there. (This reflects an underlying ipython issue.)
- Breakpoints set in a class inheriting HasTraits are not executed in Canopy's debugger when .configure_traits() is called.
Variable browser
- Click-into browsing is not supported for nested objects other than lists, tuples, 1D- and 2D-arrays, or dicts. Please directly enter into the variable browser, the name of the nested object that you wish to inspect or edit.
- Browsing of large arrays is not supported ("large" means more than 1000 rows or more than 100 columns). The easiest workaround is to browse a view of a large array. The view can be created by slicing or reshaping.
Other
- Debugging multiple threads is not supported.
- When debugging a GUI application, it may be necessary to disable PyLab mode in Canopy's Preference dialog (Python tab), so that the application runs in its own event loop rather than in IPython's.
Please do not enter support requests in article comments
Please use article comments for suggestions to improve the article. For individual support requests, please follow these guidelines.
"The debugger has only limited functionality when used with a Python 3.x kernel (User Python environment) in Canopy 2.0." Is this still an issue with the current version of Canopy? If so, what is the timetable for addressing this?
Thanks for spotting this, Phillip. The debugger has been fully functional with Python 3 since spring 2017. Apologies for the confusion.