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 - The Python Debugger extension then creates and opens a launch.json file that contains a pre-defined configuration based on what you previously selected, in this case, Python File.
Discussions

Debugging an active python file that creates launch.json is debugging launch.json
Select Python Debugger and in the next prompt select Python File 🐛 Launch.json is created and opened. Python Debugger runs and debug the launch file. ... bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugverifiedVerification ... More on github.com
🌐 github.com
0
November 3, 2021
Debug for reading JSON file with Python Pandas - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Ask questions, find answers and collaborate at work with Stack Overflow for Teams More on stackoverflow.com
🌐 stackoverflow.com
March 29, 2016
In the debugger I often have to convert python dict to json is there a better way than evaluate expression with json.dumps()?
You are leaving out the critical explanation of why you are doing this. First, a Python dictionary is not automatically valid JSON. Hence, the [potential] need to leverage json.dumps. Pycharm supports macros (keystroke injection), but not automation (which is what you are really asking for). You could create your own extension, but that seems overkill. So for simplicity sake, you may want to just create a simple logging method that takes in a dictionary and calls pyperclip.copy(json.dumps(my_dict)). Don't forget to pip pyperclip. More on reddit.com
🌐 r/pycharm
3
5
March 9, 2023
VS Code Debugger not working for python
When VS Code was updated to 1.64.0 ... Python debugging. Clicking on "Run Python File" works fine. Clicking on "Debug Python File" now does nothing. This worked fine before the update. I might need to look at how to roll-back this latest update. ... Great! Exactly same issue I am facing. Clicking on "Run Python File" works fine. 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 ... 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 - The generated file contains two sections, one that configures debugging for launch and a second that configures debugging for attach. To create a launch.json file, click debug and run and click the textual link, create a launch.json file . ... ...
🌐
GitHub
github.com › microsoft › vscode-python-debugger › issues › 142
Debugging an active python file that creates launch.json is debugging launch.json · Issue #142 · microsoft/vscode-python-debugger
November 3, 2021 - bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugverifiedVerification succeededVerification succeeded ... Open a folder that has python file. Open the python file.
Author   sandy081
🌐
Sentry
blog.sentry.io › debugging-python-with-vs-code-and-sentry
Debugging Python with VS Code and Sentry | Sentry
December 13, 2024 - This has a variety of options for debugging different Python scripts and applications. For this exercise, choose the first option, Python File. 6. A file will now be created in the project directory at .vscode/launch.json. Save and exit this file. VS Code is now set up to debug the Python script.
🌐
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.
Find elsewhere
🌐
Reddit
reddit.com › r/pycharm › in the debugger i often have to convert python dict to json is there a better way than evaluate expression with json.dumps()?
r/pycharm on Reddit: In the debugger I often have to convert python dict to json is there a better way than evaluate expression with json.dumps()?
March 9, 2023 -

As the title says I often need to convert the value of a variable in the debugger to json for other purposes. So I use the evaluate expression function and type

import json
j = json.dumps(my_dict)

Then I copy the value of that "j" var to my clipboard.

I would think there should be an easier way so I don't have to repeat this over and over? I messed around int he "Customize Data View" but I couldn't get it to work the way I expected. I tried a macro but can't quite get it right. I'd like the macro to copy the name of the dict I am currently selecting dump it to json and copy the output of the dump to my clipboard.

Any info on a better way of doing this is greatly appreciated

🌐
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,
🌐
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 - You’ve learned a quick method to start debugging by running the current file. However, you can create one or more run configurations if you want more options. 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. VSCode will create a launch.json file in the .vscode folder.
🌐
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:
🌐
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
September 6, 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.

🌐
Towards Data Science
towardsdatascience.com › home › latest › a comprehensive guide to debugging python scripts in vs code
A comprehensive guide to debugging Python scripts in VS Code | Towards Data Science
March 5, 2025 - To access the JSON file, we can either click the "create a launch.json file" when first opening the debugging window in VS Code, or just by clicking the "gear" icon next to the green play button used for starting the debugging session.
🌐
Cursor
forum.cursor.com › support › bug reports
Python debugger doesn't launch - Bug Reports - Cursor - Community Forum
November 16, 2023 - I am trying to debug an extremely ... launch.json: { "version": "0.2.0", "configurations": [ { "name": "Python: Current File", "type": "python", "request": "launch", "program": "${file}", "console": ......
🌐
Microsoft Learn
learn.microsoft.com › en-us › visualstudio › python › debugging-python-in-visual-studio
Debug Python code, set breakpoints, inspect code - Visual Studio (Windows) | Microsoft Learn
Use rich interactive debugging for Python code in Visual Studio, including setting breakpoints, stepping, inspecting values, looking at exceptions, and more.
🌐
Stack Overflow
stackoverflow.com › questions › 36656305 › print-json-to-debug-python
print json to debug - python - Stack Overflow
April 15, 2016 - I have a large input file of a JSON array and python parser json.load throws an error "ValueError: Expecting , delimiter: line 1 column 60039535 (char 60039534)" How do I print the json data
🌐
Visual Studio Code
code.visualstudio.com › docs › debugtest › debugging
Debug code with Visual Studio Code
November 3, 2021 - Start a debugging session with ... like attaching to a running process, you need to create a launch.json file to specify the debugger configuration....