Actually, there is a very simple option to do this I found by accident while trying to edit the launch.json file.

"type": "python",
"request": "launch",
"pythonPath": "D:\\ProgramData\\Anaconda3\\envs\\simulec\\python.exe",
"module": "my_module.my_file",

Simply specify the module in the module key "module": "my_module.my_file"

The -m is not useful any more.

Answer from dzada on Stack Overflow
🌐
Visual Studio Code
code.visualstudio.com › docs › python › debugging
Python debugging in VS Code
November 3, 2021 - For general debugging features such as inspecting variables, setting breakpoints, and other activities that aren't language-dependent, review VS Code debugging. This article mainly addresses Python-specific debugging configurations, including the necessary steps for specific app types and remote debugging.
🌐
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 - 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. Here is one of my modified ones. { // 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: crewai series day_04", "type": "debugpy", "request": "launch", "program": "${file}", "console": "integratedTerminal", "env": { "PYTHONPATH": "${workspaceFolder}\\crewai_series"
Discussions

How to debug a Python module in Visual Studio Code's launch.json - Stack Overflow
When I need to run a module, I ... "Run and Debug" tab of the Activity Bar ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... New site design and philosophy for Stack Overflow: Starting February 24, 2026... I’m Jody, the Chief Product and Technology Officer at Stack Overflow. Let’s... 35 How to configure VS code for pytest with environment variable · 23 How to make VScode launch.json for a Python ... More on stackoverflow.com
🌐 stackoverflow.com
How to debug remote Python script in VS Code - Stack Overflow
I don't think localhost will work here. Localhost will connect to the machine where vscode is running while we want to connect to the machine where debugpy is running and the IP doesn't have to be a public IP, infact all of this work can be done offline without internet. More on stackoverflow.com
🌐 stackoverflow.com
Visual Studio Code: How debug Python script with arguments
Hi team I need to debug a script called find.py with arguments, but I don’t know where I need to put the arguments. By line command the script run ok. I need to run by Debug button in visual code. find.py -s 0V1JXON178… More on discuss.python.org
🌐 discuss.python.org
0
0
July 3, 2024
Debugging python in vscode
Inside debbug configurations set parent path in "cwd" "version": "0.2.0", "configurations": [ { "name": "Python Debugger: Current File", "type": "debugpy", "request": "launch", "program": "${file}", "console": "integratedTerminal", "cwd": "C:/Users/chris/parent/path", "env": { "PYTHONPATH": "${cwd}" } } ] } More on reddit.com
🌐 r/learnpython
5
2
March 28, 2022
🌐
Visual Studio Code
code.visualstudio.com › docs › python › python-quick-start
Quick Start Guide for Python in VS Code
November 3, 2021 - To start debugging, initialize the debugger by pressing F5. Since this is your first time debugging this file, a configuration menu will open allowing you to select the type of application you want to debug.
🌐
Visual Studio Code
code.visualstudio.com › docs › containers › debug-python
Debug Python within a container
November 3, 2021 - How to configure and troubleshoot debugging of Python apps running in a container, using Visual Studio Code.
🌐
Visual Studio Code
code.visualstudio.com › docs › debugtest › debugging
Debug code with Visual Studio Code
November 3, 2021 - For debugging other languages and runtimes (including PHP, Ruby, Go, C#, Python, C++, PowerShell and many others), look for Debuggers extensions in the Visual Studio Marketplace, or select Install Additional Debuggers in the top-level Run menu.
Find elsewhere
🌐
Sentry
blog.sentry.io › debugging-python-with-vs-code-and-sentry
Debugging Python with VS Code and Sentry | Sentry
December 13, 2024 - VS Code is now set up to debug the Python script. To launch the script in debugging mode, click the green arrow at the top of the Run and Debug sidebar or press F5 on your keyboard.
Top answer
1 of 4
19

I have resolved this issue. If anyone wants to do remote development and debugging, follow below steps:

  1. Install remote ssh extension in VS code
  2. Once installed, you will find a green icon on the bottom left corner in vs code which allows us to connect to the remote machine.
  3. Connect to the remote machine using the standard ssh command. Alternatively, you can use ssh-keygen to generate a public-private key if you don't want to use the password at every prompt.
  4. Once you are connected to remote machine, you can open the file explorer and create any python file. When you will save this, it will get saved in your remote machine. This way you are using your machine to remotely develop code on another remote machine.
  5. Good thing about vs code is that it selects the remote machine's python interpreter so all the packages which you have installed on your remote machine will work with IntelliSense.
  6. In order to debug the code, we will use debugpy. Install this on both machine (remote & local)
  7. On your remote machine, run below command:

python3 -m debugpy --listen 1.2.3.4:5678 --wait-for-client app.py

here 1.2.3.4 is the IP of remote machine. This will start a remote debugger which will wait for a clients connection.

  1. On your local machine, in VS code open Run & Debug, add a configuration of Python: Remote Attach. Make sure that launch.json has the host as the IP of your remote machine and port as 5678.
  2. Now start debugging as normal and you will notice the code will break at first breakpoint and from here you can proceed normally as we used to do in local debugging process.

TBH, this is best feature VS code has because most of the software allows you to do remote development which is nothing but just a normal SSH but remote debugging gives you more control. I was doing some python project on Raspberry Pi and obviously cannot install VS code or pycharm on it. But with this feature now I can easily develop the code using Pi's python interpreter and debug it as well.

If anyone is having any issues, let me know. Happy to help.

2 of 4
4

It is frustrating there are so many out-dated instructions how to remote debug Python scripts from VSC.

As of August 2024 there is a far easier way to set this up that answers the OP's question which involved VSC being installed on a laptop and debugging a Python script saved on a Raspberry Pi also in the same LAN.

Once you have installed the Remote SSH extension on your local machine use that to SSH via VSC in to your remote machine. Now install the Python Debugger extension on your remote system.

Since you have ssh'd in to that remote system via the VSC extension VSC just debugs the script on that remote system as though it is LOCAL.

  1. Place a breakpoint (red dot) on the line you want script execution to stop at.
  2. From File Menu > Run > Start Debugging (F5)... The Command Palette will open and it will say:
  3. Select Debugger <-- Choose Python Debugger
  4. Then choose...
  5. Python File Debug the currently active Python File.
  6. Now use F10, F11 etc to step through the lines of code.

You DO NOT need to...

  • Do ssh local port forwarding.
  • Separately install debugpy from the command line in your local and remote environments.
  • Run debugpy from the command line.
  • Have a copy of the Python script in your local environment AND another on the remote environment. You only need ONE copy in the remote environment.
  • You don't even need a launch.json.

I checked about what sockets were opened by separately ssh'ing from a Terminal in to the "remote system" (my Raspberry Pi running Ubuntu) and they are all localhost.

ubuntu@ubuntu:~$ lsof -i
COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
code-f1e1 76603 ubuntu    9u  IPv4 519530      0t0  TCP localhost:43675 (LISTEN)
code-f1e1 76603 ubuntu   12u  IPv4 519534      0t0  TCP localhost:43675->localhost:34540 (ESTABLISHED)
python    77190 ubuntu    4u  IPv4 520559      0t0  TCP localhost:39819 (LISTEN)
python    77190 ubuntu    8u  IPv4 522535      0t0  TCP localhost:45381 (LISTEN)
python    77190 ubuntu    9u  IPv4 521557      0t0  TCP localhost:45381->localhost:59082 (ESTABLISHED)
python    77190 ubuntu   11u  IPv4 521558      0t0  TCP localhost:35979->localhost:37454 (ESTABLISHED)
python    77218 ubuntu    3u  IPv4 520157      0t0  TCP localhost:37454->localhost:35979 (ESTABLISHED)
python    77228 ubuntu    3u  IPv4 520164      0t0  TCP localhost:59082->localhost:45381 (ESTABLISHED)
🌐
Qt
doc.qt.io › qtforpython-6 › tutorials › debugging › vscode › vscode.html
Debugging PySide with VSCode (Linux + Windows) - Qt for Python
Run “(gdb) Attach” or “(Windows) Attach” and this should ask you for the processId of the Python process to which you want to attach the C++ debugger. VSCode also lets you search for the process by its name.
🌐
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 article will guide you through the process of setting up and using VSCode to debug a Python module, from initial setup to advanced debugging techniques.
🌐
DEV Community
dev.to › j0nimost › debugging-python-in-vs-code-mg7
Debugging Python in VS Code - DEV Community
January 28, 2019 - First you need to open a terminal ... ... We can now enable debugging in vscode you can do this by using f5 or by clicking debug from menu tab the start with debugging When activated you should see a debug panel....
🌐
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.
🌐
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 - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Python Debugger: Current File with Arguments", "type": "debugpy", "request": "launch", "program": "${workspaceFolder}/my_project/runner.py", "console": "integratedTerminal", "args": ["arg1", "arg2"] } ] }
🌐
Python.org
discuss.python.org › python help
Visual Studio Code: How debug Python script with arguments - Python Help - Discussions on Python.org
July 3, 2024 - Hi team I need to debug a script called find.py with arguments, but I don’t know where I need to put the arguments. By line command the script run ok. I need to run by Debug button in visual code. find.py -s 0V1JXON178R0G007NZ6 -f message.log.2024-06-05_1929.2024-06-05_1931.cexpgtap4p.gz,message.log.2024-06-05_1931.2024-06-05_1933.cexpgtap4p.gz,message.log.2024-06-05_1932.
🌐
Visual Studio Code
code.visualstudio.com › docs › python › python-web
Run and Debug Python in the Web
November 3, 2021 - The extension comes with an integrated Python REPL. To activate it, run the command Python WASM: Start REPL. There is support for debugging Python files on the Web and it uses the same UI as VS Code Desktop debugging.
🌐
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 - Learn to debug Python in VS Code with breakpoints, real-time tracking, and advanced techniques for seamless coding.
🌐
Ben Selby
benmatselby.dev › post › debugging-python-with-env-vscode
Debugging Python with a virtual environment in VSCode · Ben Selby
October 30, 2022 - I did know it was a virtual environment issue though. After some digging, I found out you have to pick your default interpreter. In VS Code open the Command Palette (⇧ ⌘ P). Then select “Python: Select Interpreter".
🌐
Reddit
reddit.com › r/learnpython › debugging python in vscode
Debugging python in vscode : r/learnpython
March 28, 2022 - Make it into a package and install it prior to debugging. I cannot overemphasize how this step solves a lot of the problems you and many others have with running Python. Magically, all your import errors will be easy to fix, there will be only one way to run your code, the path will be predictable.
🌐
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.
🌐
GitHub
github.com › microsoft › vscode-python › discussions › 21193
Can we start vscode debugger directly from terminal with `python --pdb`? · microsoft/vscode-python · Discussion #21193
pip install debugpy python -m debugpy --listen 5678 --wait-for-client your_command.py ... Your IDE breakpoints work as usual. This respects VS Code’s architecture and avoids manual breakpoint() calls. References: ... Working on a PR to include a simple attach wrapper in vscode-python examples.
Author   microsoft