# Debugging Python CLI Arguments in VSCode

By Corey J. Gallon · 2024-09-15 · https://gallon.me/debugging-python-programs-that-require-cli-arguments-in-vscode.html

---

Command Palette (CTRL+SHIFT+P):  Debug: Add Configuration

![Command Palette Debug Config.png](https://gallon.me/images/20240911_command_palette_debug_config.png)

Then, select “Python Debugger”

![Command Palette Python Debugger.png](https://gallon.me/images/20240911_command_palette_python_debugger.png)

Then, select “Python File with Arguments”

![Command Palette Python File with Arguments.png](https://gallon.me/images/20240911_command_palette_python_file_with_arguments.png)

VSCode then creates the `.vscode` directory in your project, if it doesn’t exist already, and adds `launch.json` as follows:

```json
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://code.visualstudio.com/docs/debugtest/debugging
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Current File with Arguments",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "args": "${command:pickArgs}"
        }
    ]
}
```

If you don’t change anything, when you debug a file VSCode will prompt you for arguments to pass the file every time you run the debugger.

![VSCode Prompt for Arguments.png](https://gallon.me/images/20240911_vscode_prompt_for_arguments.png)

Can also click, bottom right, “Add Configuration” which will stub out adding more configs in the JSON so that you can tailor it to your specific application.  For example:

```json
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://code.visualstudio.com/docs/debugtest/debugging
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Blue Horseshoe Debugger",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "args": ["run", 
            "--players", "5", 
            "--duration", "2", 
            "--round-end", "fixed", 
            "--config", "strategy_config.yaml", 
            "--simulation", "true", 
            "--strategies", "conservative,conservative,conservative,momentum,arbitrage"]
        },
        {
            "name": "Python Debugger: Current File with Arguments",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "args": "${command:pickArgs}"
        }
    ]
}
```
