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

VS Code调试Django项目无响应问题求助

Windows下VS Code调试Python3.6 Django项目无响应问题排查方案

在Windows系统中使用VS Code调试Python 3.6版本的Django项目时,点击调试按钮无任何反馈,但在终端执行python manage.py runserver可正常启动项目。已尝试两种launch.json配置仍未解决问题,配置代码如下:

第一种Django专用配置

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Django",
            "python": "C:/Users/msekmani/Desktop/dashboard_project/venv/Scripts/python.exe",
            "type": "python",
            "request": "launch",
            "program": "C:/Users/msekmani/Desktop/dashboard_project/IPv2/src/manage.py",
            "console": "internalConsole",
            "args": ["runserver"],
           "django": true,
           "justMyCode": true,
        },
    ]
}

第二种Python当前文件配置

{
"version": "0.2.0",
"configurations": [
    {
        "name": "Python: Current File",
        "type": "python",
        "request": "launch",
        "program": "${file}",
        "console": "integratedTerminal",
        "justMyCode": true
    }
  ]
}

排查与解决步骤

  1. 确认Python解释器关联

    • 点击VS Code左下角状态栏的Python版本,选择项目虚拟环境中的C:/Users/msekmani/Desktop/dashboard_project/venv/Scripts/python.exe,避免全局解释器与虚拟环境冲突。
  2. 修正Django配置的格式与参数

    • 删除配置中"justMyCode": true,末尾的逗号(JSON不允许尾逗号);
    • 将console改为integratedTerminal,内部控制台可能无法显示启动报错,切换到集成终端可查看具体问题;
    • 可将program路径改为${workspaceFolder}/IPv2/src/manage.py,使用工作区变量避免绝对路径问题。调整后的配置示例:
      {
          "version": "0.2.0",
          "configurations": [
              {
                  "name": "Django",
                  "python": "C:/Users/msekmani/Desktop/dashboard_project/venv/Scripts/python.exe",
                  "type": "python",
                  "request": "launch",
                  "program": "${workspaceFolder}/IPv2/src/manage.py",
                  "console": "integratedTerminal",
                  "args": ["runserver"],
                  "django": true,
                  "justMyCode": true
              }
          ]
      }
      
  3. 检查调试依赖与扩展兼容性

    • 在虚拟环境中执行venv/Scripts/pip install debugpy,确保调试依赖debugpy已安装;
    • 若使用的Python扩展版本过高,可能不再支持Python3.6,可降级到v2022.x系列版本。
  4. 规范当前文件配置的使用

    • 使用Python: Current File配置时,必须确保当前打开的文件是manage.py,并添加启动参数:
      {
          "version": "0.2.0",
          "configurations": [
              {
                  "name": "Python: Current File",
                  "type": "python",
                  "request": "launch",
                  "program": "${file}",
                  "console": "integratedTerminal",
                  "args": ["runserver"],
                  "justMyCode": true
              }
          ]
      }
      
  5. 检查路径与权限

    • 确认项目路径无中文、空格或特殊字符,避免Windows路径解析失败;
    • 以管理员身份启动VS Code,排除文件权限限制导致调试进程无法启动。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.11 01:50:31