You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VSCode的Python Interactive面板中调试Python模块?

Can I Set Breakpoints to Pause Execution When Calling Modules via VS Code's Python Interactive Panel?

Absolutely! You can absolutely set breakpoints in your Python module code and have execution pause when triggered via the VS Code Python Interactive panel (the Jupyter-like component). Here's a step-by-step guide to make this work smoothly:

  • Add breakpoints to your module code
    Navigate to the failing function in your Python module, then click the blank space to the left of the line number where you want execution to pause—you’ll see a red dot pop up, marking an active breakpoint. You can also use the keyboard shortcut F9 to toggle breakpoints on/off for the current line.

  • Make sure your VS Code Python extension is up to date
    Outdated versions might have compatibility issues with interactive debugging. Open the Extensions panel (Ctrl+Shift+X), search for "Python", and hit "Update" if a newer version is available.

  • Launch the Jupyter Interactive Debugging session

    1. Open the Debug panel using Ctrl+Shift+D (or click the bug icon in the left sidebar).
    2. From the dropdown menu at the top of the Debug panel, select Python: Jupyter Interactive Debugging. If this option isn’t listed, click "create a launch.json file", choose "Python" as the environment, then pick the Jupyter debugging configuration from the options.
    3. Click the green "Start Debugging" button (or press F5) to kick off the debugging session.
  • Trigger the function call in the Interactive panel
    Head back to your Python Interactive panel and re-run the code block that calls your problematic function. When execution hits your breakpoint, VS Code will automatically switch to the Debug view, where you can inspect variables, step through code line-by-line, and figure out what’s going wrong.

Quick Tip

If you’ve edited your module since importing it, run import importlib; importlib.reload(your_module_name) in the Interactive panel first. This ensures you’re debugging the latest version of your code, avoiding issues with cached old code.

内容的提问来源于stack exchange,提问作者oshi2016

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 18:52:49