【问题标题】:VS Code: "Property Debug Options Not Allowed"VS Code:“不允许属性调试选项”
【发布时间】:2018-10-14 22:42:28
【问题描述】:

我正在尝试学习 Python 并设置 VS Code 的 Python 调试器,如该视频所述:https://www.lynda.com/Python-tutorials/Choosing-editor-IDE/661773/707220-4.html

但是,讲师似乎使用的是 VS Code 1.18,而我使用的是 1.28。我将launch.json配置设置为它在视频中的显示方式,但我在“debugOptions”下得到一条绿线,上面写着“不允许使用Property debugOptions”。任何人都知道我可以如何设置我的环境,以便它按照教师解释的方式工作。我在 Windows 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"
    }
]

}

【问题讨论】:

  • “debugOptions”已从较新版本的配置选项中删除

标签: python-3.x visual-studio-code vscode-settings vscode-debugger


【解决方案1】:
       "name": "Python",
       "type": "python",
       "request": "launch",
       "stopOnEntry": true,
       "pythonPath": "${config:python.pythonPath}",
       "program": "${file}",
       "cwd": "",
       "env":{},
       "envFile": "${workspaceRoot}/.env",
       "console": "none" //add this and go

【讨论】:

    【解决方案2】:

    代替

            "debugOptions": [
                "RedirectOutput"
            ],
    

    使用

            "redirectOutput": true,
    

    等等。在VSCode debugging documentation 检查正确的配置选项(以及是否需要它们)。乍一看,我似乎找不到前两个选项,请考虑您是否需要它,如果需要,请在 Google 上搜索。

    你的整个第一个配置块将是

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

    【讨论】:

      猜你喜欢
      • 2022-10-17
      • 2021-07-16
      • 1970-01-01
      • 2019-04-07
      • 1970-01-01
      • 2021-04-27
      • 2014-05-23
      • 2021-11-27
      • 1970-01-01
      相关资源
      最近更新 更多