Search code examples
pythonvisual-studio-codevscode-debugger

How can I pass arguments to the python interpreter like "-u" in launch.json configurations?


I am trying to call python -u file.py in VS Code debug mode. I get that I can use the "args" field to specify arguments, but what about python interpreter flags?


Solution

  • If you're using "type": "python" in your launch configuration, just use the "pythonArgs" field and pass an array of arguments (as strings) to pass to the python interpreter.

    That field's description:

    Command-line arguments passed to the Python interpreter. To pass arguments to the debug target, use "args".

    For example:

    {
        "configurations": [
            {
                "name": "Python: Current File",
                "type": "python",
                "request": "launch",
                "program": "${file}",
                "console": "integratedTerminal",
                "justMyCode": true,
                "pythonArgs": ["-u"]
            }
        ]
    }