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 - By default, the debugger uses the same interpreter selected for your workspace, just like other features of Python extension for VS Code. To use a different interpreter for debugging specifically, set the value for python in launch.json for the applicable debugger configuration.
Discussions

Issues with running Python on VS Code
Were you using a venv? If I understand correctly, it's asking for the python executable so either select your system one or create a venv and select that. launch.json is for debugging, you won't need it to execute your program normally. More on reddit.com
🌐 r/learnpython
4
0
January 7, 2025
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
VS Code launch.json for debugging runwsgi - Development - Plone Community
Here's a launch.json I got working to debug a Plone Classic add-on that uses runwsgi (you will probably need to change the PYTHONPATH value that I used, in the last line): { "version": "0.2.0", "configurations": [ { "name": "Launch runwsgi with debugpy", "type": "debugpy", "request": "launch", ... More on community.plone.org
🌐 community.plone.org
0
November 3, 2025
Says my "Python: file" is missing from launch.json
please help asap, i’ve trying repairing it from the setup, does not work More on discuss.python.org
🌐 discuss.python.org
0
0
June 28, 2023
🌐
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 - To create a launch.json file, click debug and run and click the textual link, create a launch.json file . ... Select Python Debugger from the Command Palette. From the list of debug configurations that appear, select thePython file with arguments ...
🌐
Reddit
reddit.com › r/learnpython › issues with running python on vs code
r/learnpython on Reddit: Issues with running Python on VS Code
January 7, 2025 -

So I have a data analysis script rn, no errors, and I ran it a month ago on the same pc with no errors and I can run it on google colab.
I had this issue on my laptop recently but I assumed it was only for my laptop. That wasn't the case. Essentially it asks nonstop, "Select a python interpreter" with 2 options that just go to the same file path, just one has a gear icon and the whole file path listed whereas the 2nd has only the end hal.f of the file path. Neither option changes anything, they both then bring up "Debug stopped, open 'launch.json' ".

After that it asks me for a directory, and it never works. I just try anyway I can to get to the Desktop (where my file is stored) and nothing pops up or even goes through.

Does anyone have a solution for this? Or any experience?
It just sucks how this happens out of the blue

🌐
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
🌐
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 - Modify the JSON to look like this: { "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)
Find elsewhere
🌐
Plone Community
community.plone.org › development
VS Code launch.json for debugging runwsgi - Development - Plone Community
November 3, 2025 - Here's a launch.json I got working to debug a Plone Classic add-on that uses runwsgi (you will probably need to change the PYTHONPATH value that I used, in the last line): { "version": "0.2.0", "configurations": [ { "name": "Launch runwsgi with debugpy", "type": "debugpy", "request": "launch", "program": "${workspaceFolder}/.venv/bin/runwsgi", "args": [ "instance/etc/zope.ini" ], "console": "integratedTerminal", "cwd": "${workspace...
🌐
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 - Assuming you’re already set up with Python and VS Code, we’ll jump right into the debugging features. Let’s set up VS Code’s debugging properly. The launch.json file will serve as your control center for debugging configurations:this is where you tell VS Code exactly how to run your debug sessions.
🌐
Medium
m-ruminer.medium.com › vscode-and-debugging-python-in-virtual-environments-d975125b455c
VSCode and Debugging Python in Virtual Environments | by Michael Ruminer | Medium
January 10, 2026 - I recently found how to debug Python with breakpoints and watches in a virtual environment, or at least in the default “-m venv” virtual environment, much as I would in a different language in Visual Studio . You can have the debug window create a launch.json in the .vscode folder of the root workspace directory or create it yourself from scratch.
🌐
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.

🌐
YouTube
youtube.com › watch
Debugging Python with Visual Studio Code (VSCode) - YouTube
In this tutorial, we will guide you through the process of debugging Python code with Visual Studio Code (VSCode). VSCode is a popular code editor with debug...
Published   April 19, 2023
🌐
Medium
blog.dataengineerthings.org › debugging-like-a-champ-python-c9a4626b6a7a
Debugging like a Champ — Python
August 31, 2025 - To set up your debugger. Follow the following steps: Step 1: Click on the Run and Debug icon and create a launch.json file
🌐
Code with Mosh
forum.codewithmosh.com › python
VS.Code Launch.json - Python - Code with Mosh Forum
July 15, 2021 - I’m currently learning python 4.9 Debug with Mosh online course and I have a problem with my VSCode. I couldn’t reload the launch.json file when I try to debug like Mosh instructed. Can somebody help me?
🌐
Keploy
keploy.io › home › community › vscode python debugging tips & tricks
VSCode Python Debugging Tips & Tricks | Keploy Blog
August 25, 2025 - Master Python debugging in VSCode with breakpoints, step execution, and variable inspection to fix errors efficiently.
🌐
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,
🌐
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: