我在Visual Studio Code launch.json:
中有这个设置文件"name": "Django",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceFolder}/manage.py",
"cwd": "${workspaceFolder}",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput",
"Django"
]
当我点击Debug - >启动调试,它会自动生成以下语法,该语法与我上面的设置文件不同:
C:\ Users \ HP \ Work \ ABC> cd C:\ Users \ HP \ Work \ ABC&& cmd / C“set”PYTHONIOENCODING = UTF-8“&& set”PYTHONUNBUFFERED = 1“&& C:\ Users \ HP \ Work \ Scripts \ python.exe c:\ Users \ HP.vscode \ extensions \ ms-python.python-2018.5.0 \ pythonFiles \ PythonTools \ visualstudio_py_launcher.py C:\ Users \ HP \ Work \ ABC 65530 34806ad9-833a-4524-8cd6-18ca4aa74f14 RedirectOutput,RedirectOutput,DjangoDebugging C:\ Users \ HP \ Work \ ABC / manage.py runserver --noreload --nothreading “
执行上述调试器时,它总是返回不一致的错误消息,例如:
RuntimeError:在迭代期间设置更改的大小
引发异常('无法附加')异常:无法附加
答案 0 :(得分:0)
这是我launch.json中的代码:
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceFolder}/manage.py",
"cwd": "${workspaceFolder}",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
也许您可以尝试一下,它将起作用!