Visual Studio Code: How debug Python script with arguments

I'm using Visual Studio Code in order to debug a Python script.

Following this guide, I set up the argument in the launch.json file:

Enter image description here

But when I press on Debug, it says that my argument is not recognized and Visual Studio Code says:

error: unrecognized arguments

Enter image description here

As Visual Studio Code is using PowerShell, let's execute the same file with the same argument:

Enter image description here

So: the same file, same path, and same argument. In the terminal it is working, but not in Visual Studio Code.

Where am I wrong?


I think the --City and Auckland are used as a single argument. Maybe try separating them like so...

Single argument

    "args": ["--city","Auckland"]

Multiple arguments and multiple values

Such as:

--key1 value1 value2 --key2 value3 value4

Just put them into the args list one by one in sequence:

"args": ["--key1", "value1", "value2", "--key2", "value3", "value4"]


I also noticed that if you run the script by clicking on the debug button that looks like this enter image description here, then the arguments are not passed. However, using Run -> Start Debugging (or its shortcut F5) passed the arguments successfully.