通过与IPython控制台中的增强调试器集成,支持Spyder中的调试。这允许直接从Spyder GUI以及所有熟悉的IPython控制台命令查看和控制断点和执行流。 使用 ipdb 进行调试¶您可以从“调试”菜单、“调试”工具栏、可配置的键盘快捷方式以及标准控制台命令完全控制调试器的执行。 此外,编辑器还使用箭头显示调试器当前停止的代码行。 Spyder的调试器提供语法突出显示,代码完成和命令历史记录,其工作方式与普通交互式解释器完全相同。 使用向上和向下箭头调用以前的命令,然后按键触发自动完成建议。Tab Furthermore, IPython’s magic functions are available in debugging mode.
You can, for example, run to list the contents of your current working directory or to check how fast a given snippet of code is. Finally, you can enter and execute multiline statements in Spyder’s debugger just like with the regular IPython prompt, to easily run complex code. Breakpoints¶Spyder’s debugger is integrated with the Breakpoints pane, which lists the file, line, and condition (if any) of every breakpoint defined. To open it, select Debug ‣ List breakpoints, or press ( on macOS).Ctrl-Shift-BCmd-Shift-B There are several different ways to set and clear breakpoints:
You can access and edit local and global variables at each breakpoint through the Variable Explorer. Advanced features¶You can avoid stepping through other Python packages while debugging by enabling the new Ignore Python libraries while debugging option in Spyder’s preferences, under IPython Console ‣ Debugger ‣ Debug. This will skip all the built-in and third-party Python modules you have installed. If your code has variables with the same names as Pdb commands (e.g. or ), you can still refer to them as normal while debugging.
To call the respective Pdb command, just add an exclamation point before it (e.g. or ). You can have Spyder automatically execute a custom snippet of code every time the debugger stops. For example, you can use this to set specific variables, or import commonly-used modules so they are always available while debugging. To set this up, go to Preferences ‣ IPython Console ‣ Debugger ‣ Run code while debugging, and enter the code that you want to be executed with each step. Matplotlib support¶Generating Matplotlib figures is fully supported while the debugger is active, including all the different graphics backends.
Use the magic to change to an interactive backend (e.g. ) to pan, zoom and adjust your plots in a separate window, or switch back to the default () to see them displayed right in the Plots pane. To avoid showing plots while debugging, deactivate the Process execute events while debugging option in Preferences ‣ IPython console ‣ Debugger. Related panes¶ |
|