Skip to content

Instantly share code, notes, and snippets.

@asears
Created November 11, 2021 10:55
Show Gist options
  • Select an option

  • Save asears/2816d64e8876acc9309eeb0da98d9759 to your computer and use it in GitHub Desktop.

Select an option

Save asears/2816d64e8876acc9309eeb0da98d9759 to your computer and use it in GitHub Desktop.
launch.json for python
{
// 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
// options are internalConsole, integratedTerminal, externalTerminal, remote, remoteMixed, remoteMixedErrors, remoteMixedOutput, remoteMixedOutputErrors, remoteMixedErrorsOutput, remoteMixedOutputErrors
// use env and envFile to set environment variables
// use cwd for the current working folder of the debugger, defaults to the workspace root
// https://code.visualstudio.com/docs/python/debugging
// schema located at https://code.visualstudio.com/docs/python/debugging#_launchjson-schema
// tricks to get the correct path to the python executable
// https://stackoverflow.com/questions/5272409/how-to-get-the-python-executable-path-in-windows
"version": "0.2.0",
"configurations": [{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}, {
"name": "Python: Current File External Terminal",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal"
}, {
"name": "Python: Current File Console",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "internalConsole"
},
{
"name": "Python: Current File (Debug)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [
"-m",
"pdb"
],
"stopAtEntry": true,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "Python: Current File (Run)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "Python: Current File (Run with Debug)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [
"-m",
"pdb"
],
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "Python: Current File (Run with Debug and Autoreload)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"autoReload": {
"enable": true
},
"args": [
"-m",
"pdb"
],
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "Python: Current File (Run with Debug and Autoreload JustMyCode)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"autoReload": {
"enable": true
},
"args": [
"-m",
"pdb"
],
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "Python: Current File (Run with Debug and Watch)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [
"-m",
"pdb"
],
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"debugOptions": [
"RedirectOutput"
],
"env": {
"PYTHONUNBUFFERED": "1"
}
},
{
"name": "Python: Current File (Run with Watch)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"debugOptions": [
"RedirectOutput"
],
"env": {
"PYTHONUNBUFFERED": "1"
}
},
// python -m debugpy --listen 5678 ./myscript.py
{
"name": "Python: Current File (Debug with Debugpy)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [
"-m",
"debugpy",
"--listen",
"5678"
],
"stopAtEntry": true,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
}
},
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment