Код VS: параметры отладки свойства не разрешены

Я пытаюсь изучить Python и настроить отладчик Python VS Code, как описано в этом видео: https://www.lynda.com/Python-tutorials/Choosing-editor-IDE/661773/707220-4.html.

Однако инструктор, похоже, использует VS Code 1.18, а я - 1.28. Я настроил конфигурацию launch.json так, как она выглядит в видео, но я получаю зеленую строку под «debugOptions», которая говорит: «Свойство debugOptions не разрешено». Кто-нибудь знает, как я могу настроить свою среду, чтобы она работала так, как объясняет инструктор. Я на Виндовс 10.

{
// 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": "Python",
        "type": "python",
        "request": "launch",
        "stopOnEntry": true,
        "pythonPath": "${config:python.pythonPath}",
        "program": "${file}",
        "cwd": "",
        "env":{},
        "envFile": "${workspaceRoot}/.env",
        "debugOptions": [
            "WaitOnAbnormalExit",
            "WaitOnNormalExit",
            "RedirectOuput"
        ]
    },
    {
        "name": "Python: Attach",
        "type": "python",
        "request": "attach",
        "port": 5678,
        "host": "localhost"
    },
    {
        "name": "Python: Module",
        "type": "python",
        "request": "launch",
        "module": "enter-your-module-name-here",
        "console": "integratedTerminal"
    },
    {
        "name": "Python: Django",
        "type": "python",
        "request": "launch",
        "program": "${workspaceFolder}/manage.py",
        "console": "integratedTerminal",
        "args": [
            "runserver",
            "--noreload",
            "--nothreading"
        ],
        "django": true
    },
    {
        "name": "Python: Flask",
        "type": "python",
        "request": "launch",
        "module": "flask",
        "env": {
            "FLASK_APP": "app.py"
        },
        "args": [
            "run",
            "--no-debugger",
            "--no-reload"
        ],
        "jinja": true
    },
    {
        "name": "Python: Current File (External Terminal)",
        "type": "python",
        "request": "launch",
        "program": "",
        "console": "externalTerminal"
    }
]

}


person AlternativeHacks    schedule 14.10.2018    source источник
comment
debugOptions был удален из параметров конфигурации в более новых версиях.   -  person nth-attempt    schedule 06.02.2019


Ответы (1)


Вместо

        "debugOptions": [
            "RedirectOutput"
        ],

использовать

        "redirectOutput": true,

и т. д. Проверьте наличие правильных параметров конфигурации (и хотите ли вы их) в VSCode. отладочная документация. Однако на первый взгляд я не могу найти первые два варианта, подумайте, нужно ли вам это, и погуглите, если да.

Тогда весь первый блок конфигурации для вас будет

    {
        "name": "Python",
        "type": "python",
        "request": "launch",
        "stopOnEntry": true,
        "pythonPath": "${config:python.pythonPath}",
        "program": "${file}",
        "cwd": "",
        "env":{},
        "envFile": "${workspaceRoot}/.env",
        "redirectOutput": true,
    },
person LuH    schedule 15.11.2019