How to configure a python script as the default build task in VS Code
This snippet goes in your .vscode/tasks.json file. It will run the current
python file as the default build task.
commandwill invoke the python interpreter that is configured in your workspace settings.groupwill make this task the default build task.presentation:focuswill focus the terminal window when the task is run.presentation:revealwill reveal the terminal window when the task is run.
Change args to any python file if you’d like to run the same file each time.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Python: current file",
"type": "shell",
"command": "${command:python.interpreterPath}",
"args": ["${file}"],
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"focus": true,
"reveal": "always"
},
"options": {
"cwd": "${workspaceFolder}"
}
}
]
}
2023-01-03