首页 文章

用于Python的Visual Studio代码调试器

提问于
浏览
2

我在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 - > Start Debugging时,它会自动生成以下语法,该语法与我上面的设置文件不同:

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:在迭代期间设置更改的大小

  • raise Exception('无法附加')异常:无法附加

1 回答

  • 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"
            ]
    

    也许你可以尝试一下,它会工作!

相关问题