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:
But when I press on Debug, it says that my argument is not recognized and Visual Studio Code says:
error: unrecognized arguments
As Visual Studio Code is using PowerShell, let's execute the same file with the same argument:
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?
Connect to it from within VS Code using the Python "Remote Attach" debug configuration (using the default host and port settings). You can just control+c and then re-run the command with changed arguments using your shell history and command line editing facilities, for each debug run.
Go to your project properties, either by right-clicking on the project and picking "Properties" or by picking Properties from the Project menu. Click on Debug, then enter your arguments into the "Script Arguments" field. Save.
If you're only interested in debugging a Python script, the simplest way is to select the down-arrow next to the run button on the editor and select Debug Python File in Terminal.
To set command-line arguments in Visual Studio, right click on the project name, then go to Properties. In the Properties Pane, go to "Debugging", and in this pane is a line for "Command-line arguments." Add the values you would like to use on this line. They will be passed to the program via the argv array.
I think the --City and Auckland are used as a single argument. Maybe try separating them like so...
"args": ["--city","Auckland"]
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"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With