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

VS Code中Python Scrapy调试器无法在断点处停止的问题

Scrapy调试断点失效,依赖debugpy才能触发的疑惑

我用Scrapy开发网页解析程序,数据输出为JSON格式。之前调试一切正常,搁置项目数周后回到开发,发现VS Code的内置调试断点完全无法触发。

我的launch.json配置

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Crawl with scrapy",
            "type": "python",
            "request": "launch",
            "module": "scrapy",
            "cwd": "${workspaceFolder}/DSRCrawler/DSRCrawler/spiders",
            "args": [
                "crawl",
                "dsrSpider",
                "-a",
                "start=10/1/2022",
                "-a",
                "end=10/2/2022",
            ],
            "console": "internalConsole"
        }
    ]
}

已尝试的无效操作

  • 点击VS Code调试面板「RUN AND DEBUG」旁的运行按钮,或通过「运行」菜单启动调试
  • 删除并重新创建launch.json配置文件,重装VS Code
  • 在launch.json中添加"justMyCode": false配置项
  • 尝试了常见的VS Code Python断点失效的解决方案(均无效果)

临时解决办法

最终通过手动引入debugpy添加断点的方式解决了问题,代码示例:

import debugpy
...
debugpy.breakpoint()

疑惑

我不解的是,为什么必须依赖debugpy才能触发断点?目前能找到的Scrapy相关调试方案里,都没有提到需要用debugpy替代VS Code内置断点的情况。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 20:15:32