我正在尝试学习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”下显示一条绿线,上面写着“不允许使用属性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"
}
]
}
答案 0 :(得分: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
答案 1 :(得分:0)
代替
"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,
},