Visual Studio Code only supports one launch.json file. However, it supports two or more configurations that appear in the debug pane's drop down list (instead of "No Configurations").

In the DEBUG pane, either click the Config button circled in red above or click the blue link "create launch.json file":

Click it and it creates a launch.json file with debugging configurations. Edit this file and add the args in this key-pair format AND add multiple for different args including Variable Substitution!

{
    // 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
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File with my args",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "args": [
                "--username", "Jeremy",
                "--account", "Stackoverflow"
            ],
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Current File with UserName arg",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "args": ["${env:USERNAME}"],
            "console": "integratedTerminal"
        }
    ]
}

Set your desired Config Option in the drop down and put a breakpoint in your Python script, for example on the first line under def main(...) and then press F5 or Run> Start Debugging.

You can run a Python file with arguments without a debugger by selecting a configuration in debug panel, then Ctrl F5 to run it without debugging.

Pro Tip: see the Variable Substitution reference its the perfect way to automate things for the whole team by not hardcoding individuals info or settings in the configs instead using things in Build Pipelines such as Environmental Variables from the get go!

Pro Tip:

  1. Environmental Variables to override any setting.

  2. A settings (aka appSettings.json) file to override the default/shared values.

  3. Default/Shared settings (or hardcoded POCO constructor values).


    Later configuration providers overwrite the previous providers. Image courtesy Andrew Lock.

Answer from Jeremy Thompson on Stack Overflow
Top answer
1 of 13
87

Visual Studio Code only supports one launch.json file. However, it supports two or more configurations that appear in the debug pane's drop down list (instead of "No Configurations").

In the DEBUG pane, either click the Config button circled in red above or click the blue link "create launch.json file":

Click it and it creates a launch.json file with debugging configurations. Edit this file and add the args in this key-pair format AND add multiple for different args including Variable Substitution!

{
    // 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
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File with my args",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "args": [
                "--username", "Jeremy",
                "--account", "Stackoverflow"
            ],
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Current File with UserName arg",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "args": ["${env:USERNAME}"],
            "console": "integratedTerminal"
        }
    ]
}

Set your desired Config Option in the drop down and put a breakpoint in your Python script, for example on the first line under def main(...) and then press F5 or Run> Start Debugging.

You can run a Python file with arguments without a debugger by selecting a configuration in debug panel, then Ctrl F5 to run it without debugging.

Pro Tip: see the Variable Substitution reference its the perfect way to automate things for the whole team by not hardcoding individuals info or settings in the configs instead using things in Build Pipelines such as Environmental Variables from the get go!

Pro Tip:

  1. Environmental Variables to override any setting.

  2. A settings (aka appSettings.json) file to override the default/shared values.

  3. Default/Shared settings (or hardcoded POCO constructor values).


    Later configuration providers overwrite the previous providers. Image courtesy Andrew Lock.

2 of 13
8

You can add a custom task to do this. This deals with the tasks.json. You can add a default tasks.json file for you project (project folder). Follow these steps. Keyboard press Ctrl + Shift + B. It will prompt the following popup

Click on the Configure Build Task If there is already a custom tasks.json file created in the following location .vscode/tasks.json editor will open it. If not, it will give a drop down of suggestions of already existing task runners.

Our intention is to create a custom tasks.json file for our project, so to create one we need to select the Others option from the drop down. Check the screenshot below.

Once you select the Others option, you could see a default tasks.json file will get created from the root directory of the project to the location .vscode/tasks.json. Below is an example of tasks.json.

Now edit the tasks.json file to support Python.

  1. Change the Command property from "echo" to "Python"
  2. Keep showOutput as "Always"
  3. Change args (arguments) from ["Hello World"] to ["${file}"] (filename)
  4. Delete the last property problemMatcher
  5. Keep isShellCommand and version properties as unchanged
  6. Save the changes made

You can now open your .py file and run it nicely with the shortcut Ctrl + Shift + B.

Discussions

Visual Studio Code: How debug Python script with arguments - Stack Overflow
I'm using Visual Studio Code with the inbuilt Debugger 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 th... More on stackoverflow.com
🌐 stackoverflow.com
build - How to run a Python program with arguments from within Visual Studio Code? - Stack Overflow
I am running a Python program that takes some command line arguments. How can I provide these arguments when I am building a program within the Visual Studio Code? More on stackoverflow.com
🌐 stackoverflow.com
Why does VS Code IDE make passing command line arguments to the code less than obvious?
I don't quite get it, if you once understand how to use launch.json then it's pretty easy and intuitive to pass arguments. More on reddit.com
🌐 r/vscode
6
5
November 9, 2023
Allow "Run Python File in Terminal" to accept script arguments
There was an error while loading. Please reload this page · We already have the setting "python.terminal.launchArgs", which pass arguments to the python interpreter More on github.com
🌐 github.com
2
September 11, 2022
🌐
Reddit
reddit.com › r/visualstudiocode › visual studio code run python script with arguments
r/VisualStudioCode on Reddit: Visual Studio Code run python script with arguments
November 19, 2022 - This has nothing to do with my issue but I had to say it. So in pycharm you would right click the python file/script that you would like to run/debug and select Modify Run Configuration ....
🌐
Iditect
iditect.com › faq › python › running-a-python-program-with-arguments-from-within-the-visual-studio-code.html
Running a Python program with arguments from within the Visual Studio Code
Replace "Your Script Name" with the name you want for the configuration, "${file}" with the path to your Python script, and "arg1", "arg2", "arg3" with the actual arguments you want to pass to your script. ... Open the Python script you want to run. Click on the green play button in the top ...
🌐
Visual Studio Code
code.visualstudio.com › docs › python › debugging
Python debugging in VS Code
November 3, 2021 - Each element of the argument string ... "1593"], If you want to provide different arguments per debug run, you can set args to "${command:pickArgs}"....
Find elsewhere
🌐
Visual Studio Code
code.visualstudio.com › docs › python › python-tutorial
Getting Started with Python in VS Code
November 3, 2021 - In this tutorial, you will learn how to use Python 3 in Visual Studio Code to create, run, and debug a Python "Roll a dice!" application, work with virtual environments, use packages, and more!
🌐
Reddit
reddit.com › r/vscode › why does vs code ide make passing command line arguments to the code less than obvious?
r/vscode on Reddit: Why does VS Code IDE make passing command line arguments to the code less than obvious?
November 9, 2023 -

In VS Code there are two run the script buttons (image at https://imgur.com/a/qTjD0Gt) top left or top right. The left button is 'run and debug' (or run with Ctrl-F5) and the right button is 'run' or 'debug'.

Although not obvious, by editing the launch.json file I can pass command line arguments to the left run button. For the right run button, there is no easy way to pass command line arguments/parameters to the code.

Why isn't running code, (a Python script in my case) with command line arguments in the VS Code IDE more intuitively simple?

🌐
GitHub
github.com › microsoft › vscode-python › discussions › 20380
How to run with parameters? · microsoft/vscode-python · Discussion #20380
I'm wondering how I can make launch.json work for the run python file in terminal option. Beta Was this translation helpful? Give feedback. ... There was an error while loading. Please reload this page. Something went wrong. There was an error while loading. Please reload this page. ... Please read the documentation https://code.visualstudio.com/docs/python/debugging#_purpose as I linked to, as that explicitly tells you what you need to set in your launch.json for a configuration to be used for the Run button.
Author   microsoft
🌐
GitHub
github.com › microsoft › vscode-python › issues › 19810
Allow "Run Python File in Terminal" to accept script arguments · Issue #19810 · microsoft/vscode-python
September 11, 2022 - We already have the setting "python.terminal.launchArgs", which pass arguments to the python interpreter. This simple request is to allow arguments to be passed to the python file (script) that is running. Examples (existing): If we conf...
Author   diogo-rossi
🌐
DNMTechs
dnmtechs.com › running-python-files-with-arguments-in-visual-studio-code
Running Python Files with Arguments in Visual Studio Code – DNMTechs – Sharing and Storing Technology Knowledge
In this example, the Python script “my_script.py” takes command line arguments and prints them. To run this script with arguments, open the terminal in Visual Studio Code and navigate to the directory where the script is located.
🌐
Python Land
python.land › home › creating python programs › python in vscode: running and debugging
Python in VSCode: Running and Debugging • Python Land Tutorial
September 5, 2025 - { "version": "0.2.0", "configurations": [ { "name": "Run with argument", "type": "python", "request": "launch", "program": "vscode_playground.py", "console": "integratedTerminal", "args": ["Erik"] } ] }Code language: JSON / JSON with Comments (json) This configuration supplies an argument to the script: the name ‘Erik’. Note that it also specifically starts vscode_playground.py instead of the current file.
🌐
IT Management 101
itmanagement101.co.uk › home › web & software application development › python › how to set-up command line arguments in microsoft visual studio (vs studio code)
How to set-up command line arguments when debugging in Microsoft VSCode
January 7, 2024 - # Check the program has been called with the a Customer ID if len(sys.argv) < 1: print("Usage <Account Number>) customerID = input('Enter customer ID :') else: # argv[0] in Python is always the name of the script. customerID = sys.argv[1] In this code instead of just giving an error message and exiting when the program hasn’t been called with the right parameters we ask the user to enter the missing parameters at runtime.
🌐
Reddit
reddit.com › r/vscode › passing command line arguments to python scripts
r/vscode on Reddit: Passing command line arguments to python scripts
July 12, 2022 - I mean, it's doable but I don't think that's the best way. It would be better to have a menu item to debug with parameters in addition to the debug menu. That should pop up a dialog where you can enter parameters. When I'm writing a script, I'll usually run it with different inputs, not just a fixed set.
🌐
Visual Studio Code
code.visualstudio.com › docs › python › run
Running Python code in Visual Studio Code
November 3, 2021 - Whether you are experimenting with smaller lines of Python code in the REPL or ready to run a Python script, the Python extension offers multiple ways to run your code.
🌐
Medium
codelovingyogi.medium.com › vscode-debugging-python-scripts-with-args-d8ac1cf9a191
vscode: debugging python scripts with args | by diary of a codelovingyogi | Medium
March 11, 2020 - vscode: debugging python scripts with args On the top, left side of VSCode, find your debugsettings files by going to the gear icon. In launch.json you should see pre-populated settings that looks …