Setting "justMyCode": false makes it stop at breakpoint:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"stopOnEntry": true,
"justMyCode": false
},
]
}
Answer from Ashish on Stack OverflowSetting "justMyCode": false makes it stop at breakpoint:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"stopOnEntry": true,
"justMyCode": false
},
]
}
If you're using a pytest-cov module you might also wanna have a look at pytest configuration settings note:
Note If you have the
pytest-covcoverage module installed, VS Code doesn't stop at breakpoints while debugging becausepytest-covis using the same technique to access the source code being run. To prevent this behavior, include--no-covinpytestArgswhen debugging tests, for example by adding"env": {"PYTEST_ADDOPTS": "--no-cov"}to your debug configuration.
See an example configuration file (launch.json) below:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Tests",
"type": "python",
"request": "test",
"console": "integratedTerminal",
"justMyCode": false,
"env": {"PYTEST_ADDOPTS": "--no-cov"}
}
]
}
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.
json - Visual Studio Code Python debugger does not trigger breakpoints in subfolder files - Stack Overflow
VS code not working for python debugging - Python - Code with Mosh Forum
Debugger not hitting breakpoint when using a virtual environment
Breakpoints are not hitting in VS Code while debugging Python Flask app - Stack Overflow
Videos
Hello, I tried to debug multiple python files in vscode v1.80 and they all had this common problem. It looks like I can't step line by line through functions and it just steps over the whole function and the breakpoint doesn't work inside the function. How can I debug inside the python function?
I'm running the Visual Studio Community 2022 version. I'm attempting to use the debugger on a Python script, but there is an error notification next to my breakpoint which reads as follows:
The breakpoint will not currently be hit. Breakpoint in file excluded by filters
Note: may be excluded because of "justMyCode" option (default == true). Try setting "justMyCode": false in the debug configuration (e.g., launch.json)
I navigated to debug > options > general > just my code, and disabled the checkbox next to this. However, the same error message still occurs. Is there a launch.json file somewhere that needs to be edited as well?
EDIT
Here is some sample code that I have attempted to run using Visual Studio:
import os
def change_dirs(new_dir: str) -> str:
os.chdir(new_dir)
return 'Current working directory is ' + new_dir
change_dirs(input('Please enter a directory to change to:\n'))Here is a link to a screenshot that shows the above code, as well as the error message mentioned before.
And here is a link showing the "Just In Time" settings checkbox disabled. Even after disabling this setting and restarting the computer, the issue still persists.
EDIT 2:
Changed image links since imgur was not working
I'm running the Visual Studio Community 2022 version. I'm attempting to use the debugger on a Python script, but there is an error notification next to my breakpoint which reads as follows:
The breakpoint will not currently be hit. Breakpoint in file excluded by filters
Note: may be excluded because of "justMyCode" option (default == true). Try setting "justMyCode": false in the debug configuration (e.g., launch.json)
I navigated to debug > options > general > just my code, and disabled the checkbox next to this. However, the same error message still occurs. Is there a launch.json file somewhere that needs to be edited as well?
EDIT
Here is some sample code that I have attempted to run using Visual Studio:
import os
def change_dirs(new_dir: str) -> str:
os.chdir(new_dir)
return 'Current working directory is ' + new_dir
change_dirs(input('Please enter a directory to change to:\n'))Here is a link to a screenshot that shows the above code, as well as the error message mentioned before.
And here is a link showing the "Just In Time" settings checkbox disabled. Even after disabling this setting and restarting the computer, the issue still persists.
EDIT 2:
Changed image links since imgur was not working
I had the same problem and it turn out that it was due to having installed pytest-cov.
The solution is to add the argument --no-cov to python.testing.pytestArgs, as it is pointed in the documentation
Credits to this asnwer for getting me in the right track.
You will need to change your setting "justMyCode" to false for breakpoints to work in vscode.
More can be read Here
For others, the issue has been resolved, see release notes: "Just My Code" for notebook cell debugging.
"Just My Code" for notebook cell debugging
The "Just My Code" debug feature allows the user to determine whether the debugger will step through code from Python libraries, or will only step through user code. This has been enabled by default when debugging a notebook cell, and you can now set
"jupyter.debugJustMyCode": falseto disable it and allow stepping through library code. For the best experience, upgradedebugpyin your environment to >=1.6.3. Previously, this setting was only respected for debugging using the Interactive Window. Now it is respected in notebook editors as well.
Evidently, the problem I'm encountering is a known bug: https://github.com/microsoft/vscode-jupyter/issues/8146 . I've heard from a VS Code developer that they've (tried) to implement fixes and I should try the latest Insiders vscode build, with the latest pre-release Jupyter extension. I'm not sure I'm ready for bleeding edge, so may live with the bug until these fixes end up in a standard release.
