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 } ] }
排查与解决步骤
确认Python解释器关联
- 点击VS Code左下角状态栏的Python版本,选择项目虚拟环境中的
C:/Users/msekmani/Desktop/dashboard_project/venv/Scripts/python.exe,避免全局解释器与虚拟环境冲突。
- 点击VS Code左下角状态栏的Python版本,选择项目虚拟环境中的
修正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 } ] }
- 删除配置中
检查调试依赖与扩展兼容性
- 在虚拟环境中执行
venv/Scripts/pip install debugpy,确保调试依赖debugpy已安装; - 若使用的Python扩展版本过高,可能不再支持Python3.6,可降级到v2022.x系列版本。
- 在虚拟环境中执行
规范当前文件配置的使用
- 使用
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 } ] }
- 使用
检查路径与权限
- 确认项目路径无中文、空格或特殊字符,避免Windows路径解析失败;
- 以管理员身份启动VS Code,排除文件权限限制导致调试进程无法启动。
内容的提问来源于stack exchange,提问作者MohamedAmineSekmani
相关产品推荐
相关产品推荐

