The Python extension is broken - just seems to have updated at the same time as VS Code.
Go back to extension version v2021.12.1559732655 by clicking on the extensions control and selecting "Install another version...". Note that you will have to disable "Extensions: Auto Update", which might be a good thing. I also set "Update: Mode" to "none" for good measure.
Answer from NickS on learn.microsoft.com
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
Visual Studio Code Debugger not launching - Stack Overflow
VS Code does not use launch.json arguments when I press Debug Python File
How to fix VS code debug failure for python
Run pytest in debug mode 'Debug Stopped' error message, check launch.json
Videos
The Python extension is broken - just seems to have updated at the same time as VS Code.
Go back to extension version v2021.12.1559732655 by clicking on the extensions control and selecting "Install another version...". Note that you will have to disable "Extensions: Auto Update", which might be a good thing. I also set "Update: Mode" to "none" for good measure.
So this bug is back with Python Extension version v2022.10.1 running on Ubuntu 18.04 with python 3.6.9.
This is a serious bug that keeps happening.
I had to roll back to extension version v2021.12.1559732655 to debug.
I was in similar situation and couldn't find relevant resolutions:
Quick Answer: After upgrade to VS Code 1.56.2, make sure to remove old breakpoints and create new breakpoint and at-least have 1 breakpoint and launch.json available.
Lengthy details:
I have similar issue for python scripts when I start the "debugger bar" I see it for a couple of seconds the top debugging bar and then it disappears. Bu then no message on the console, nothing. I tried reinstalling VS Code, enabling/disabling extension, various restart.
- OS and Version: Mac OSX Version 11.4 (20F71)
- VS Code Version: 1.56.2
- Extension: Python v2021.5.842923320 by Microsoft
RootCause:
What I did know for sure that I updated my VS Code, and after that this mysterious issue start happening, so when to release log of VS Code 1.56.2. I found below release log
Debug view displayed on break#
The default value of the debug.openDebug setting is now openOnDebugBreak so that on every breakpoint hit, VS Code will open the Debug view. The Debug view is also displayed on first session start.
So VS code Version 1.56 release, debugger will only show when at-least 1 breakpoint is found. However, looks like there is issue with their internal code checking for historical breakpoint data after VS Code upgrade..
https://code.visualstudio.com/updates/v1_56#_debug-view-displayed-on-break
Sometimes you should just clear the Cache and reload the window:
Open the Command Palette in Visual Studio Code by pressing Ctrl+Shift+P.
Type "Python Debugger"
Choose "Clear Cache and Reload Window"
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.
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
This is an example of my launch.json that I use to debug Python modules.
It has an additional configuration to debug "current file" (not as module) which is useful to keep.
{
linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "path.to.module",
"args": ["run_example --arg <arg>"],
"justMyCode": true
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
}
]
}
This would replicate a terminal command to run a Python module like so:
python -m path.to.module run_example --arg <arg>
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?

