Specify the module you want to run with "module": "torch.distributed.launch"

You can ignore the -m flag. Put everything else under the args key.

Note: Make sure to include --nproc_per_node and the name of file (main_swav.py) in the list of arguments

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "debugpy",
            "module": "torch.distributed.launch",
            "request": "launch",
            "console": "integratedTerminal",
            "args": [
                "--nproc_per_node", "1", 
                "main_swav.py",
                "--data_path", "/dataset/imagenet/train",
            ]
        }
    ]
}

Read more here: https://code.visualstudio.com/docs/python/debugging#_module

Answer from Matt Spataro on Stack Overflow
🌐
Visual Studio Code
code.visualstudio.com › docs › python › debugging
Python debugging in VS Code
November 3, 2021 - To initialize debug configurations, ... do the following steps: Select the create a launch.json file link (outlined in the image above) or use the Run > Open configurations menu command....
🌐
Visual Studio Code
code.visualstudio.com › docs › debugtest › debugging-configuration
Visual Studio Code debug configuration
1 week ago - Learn how to configure debugging in Visual Studio Code with launch.json, including attributes, variable substitution, and compound configurations.
Discussions

VS Code does not use launch.json arguments when I press Debug Python File
Does this issue occur when all extensions are disabled?: Yes VS Code Version: 1.63.1 OS Version: macOS Monterey 12.0.1 Steps to Reproduce: Open VS Code for Mac Open a folder containing a python fil... More on github.com
🌐 github.com
4
December 16, 2021
How to debug a Python module in Visual Studio Code's launch.json - Stack Overflow
My question may seem simple but, I have a module that I launch in a terminal like this: python -m my_module.my_file How do I debug this in Visual Studio Code? I have this in my launch.json ( More on stackoverflow.com
🌐 stackoverflow.com
How to fix VS code debug failure for python
This is what my VS code is displaying even when i try to debug a simple python file of print("Hello World"). I have used Vs code for about a year now and it has never happened. I even re-installed it but it still displays the same. I have even… More on learn.microsoft.com
🌐 learn.microsoft.com
4
0
October 9, 2025
VS Code Debugger not working for python
Clicking on "Debug Python File" now does nothing. Let me know if you get any workaround. ... I have a similar problem -- launch.json seems to be completely ignored for run or debug. I tried the switch to an old version of the intellisense extension to no effect. I am running latest VSCode on Ubuntu ... More on learn.microsoft.com
🌐 learn.microsoft.com
7
3
🌐
Medium
medium.com › @jonathan_b › debugging-in-visual-studio-code-a-python-app-with-arguments-8d75a69bbd66
Debugging in Visual Studio Code — A Python app with arguments | by BLAKELY | Medium
June 25, 2024 - A launch.json file is used to configure the debugger in Visual Studio Code. Visual Studio Code generates a launch.json (under a .vscode folder in your project) with almost all of the required information.
🌐
Donjayamanne
donjayamanne.github.io › pythonVSCodeDocs › docs › debugging
Debugging | Python in Visual Studio Code
Debugging a standard python application is possible by adding the standard configuration settings in the launch.json file as follows:
🌐
Qodo
qodo.ai › blog › learn › tutorial: how to debug python code in visual studio code
Tutorial: How to Debug Python code in Visual Studio Code - Qodo
September 17, 2025 - VS Code’s debugger automatically uses your selected Python interpreter, but you can override this in launch.json if needed.
🌐
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 - Such a configuration allows you to store specific parameters, so we can start the program exactly how we want it to. To create a run configuration, click Run -> Add Configuration. Pick the ‘Python file’ option again.
Find elsewhere
🌐
GitHub
github.com › microsoft › vscode › issues › 139251
VS Code does not use launch.json arguments when I press Debug Python File · Issue #139251 · microsoft/vscode
December 16, 2021 - What is really baffling to me is nowhere in the documentation does it state the Debug Python file button does not pass arguments. Is there a way to force that button to use my launch.json? I rarely have the Run&Debug pane open so I have to do 2 extra clicks to get to this and on a Mac with my Logitech keyboard, pressing F5 requires me to move my fingers way off the middle to do Fn-F5.
Author   ejkitchen
🌐
Medium
sanborse.medium.com › debugging-python-script-in-vscode-e865b7d6dab5
Debugging Python Script in VSCode | by Santosh Borse | Medium
September 30, 2021 - I started with simple python code file — sample-debug.py · Click on “Run and Debug” button ( on leftmost pane ) and click a link “create a launch.json file”, and select workspace of folder to save launch.json and select Python file,
🌐
Visual Studio Code
code.visualstudio.com › docs › debugtest › debugging
Debug code with Visual Studio Code
November 3, 2021 - For more complex debugging scenarios like attaching to a running process, you need to create a launch.json file to specify the debugger configuration.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 5580830 › how-to-fix-vs-code-debug-failure-for-python
How to fix VS code debug failure for python - Microsoft Q&A
October 9, 2025 - two properly debug your script in VS code, you need to tell the debugger about arguments to pass through your script by modifying your launch.json file. ... b. find the relevant configuration for running the current file(it should look similar ...
🌐
Sentry
blog.sentry.io › debugging-python-with-vs-code-and-sentry
Debugging Python with VS Code and Sentry | Sentry
December 13, 2024 - 3. With the Python project open, navigate to the Run and Debug tab on the sidebar and click create a launch.json file. 4. In the debugger options menu that appears, select Python Debugger.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-debug-a-python-module-in-vscode
How to debug a python module in VSCode - GeeksforGeeks
July 23, 2025 - This configuration tells VSCode how to run and debug your code. First, open the Debug view by clicking on the debug icon in the activity bar. Then click on the gear icon to open the 'launch.json' file.
🌐
VS Code debug specs
vscode-debug-specs.github.io › python
How to Debug Python with VS Code | VS Code debug specs - Python
{ "version": "0.2.0", "configurations": [ { "name": "Python", "type": "python", "request": "launch", "program": "${workspaceFolder}/main.py", "args": ["4", "3", "2", "1"] } ] }
🌐
Reddit
reddit.com › r/vscode › can't use python debugger because it changes cwd
r/vscode on Reddit: Can't use python debugger because it changes cwd
November 4, 2024 -

I'm trying to debug a program with the python debugger. When I run the debugger, it changes my cwd to a different folder, and I get an error because of missing files. I change the cwd again, but I get the same problem

Essentially, every time I run the debugger, it changes my cwd do a different directory and gives me an error. How do I get around this?

🌐
Reddit
reddit.com › r/vscode › vs code python syntax error in launch.json
r/vscode on Reddit: VS code python syntax error in launch.json
October 10, 2023 -

I'm trying to debug Python in VS Code. I click "create a launch.json file", select Python as the debugger, and then Python File.

When I click "run and debug", I get a syntax error in the monitor on the first (commented) line in the launch.json file that VS Code just created. I haven't edited the file. Why does the default file not work?

Edit: if I delete the comments, I get a different error name 'true' is not defined.

🌐
Visual Studio Code
code.visualstudio.com › Search
Visual Studio Code documentation search
November 3, 2021 - Learn how to create a launch.json file to specify the debugger configuration for your project in VS Code.