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"}
}
]
}
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?
Debugger does not stop on breakpoints (python. VS code)
Breakpoints not hit.
VS Code Debugger not working for python
VS code not working for python debugging - Python - Code with Mosh Forum
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.
Update
The issue has been closed and I have received confirmation that it was related to the Python version 3.9.3 (64 bit).
https://github.com/microsoft/vscode-python/issues/15865
Original Post
This has been driving me nuts and needs further investigation, but what I noticed
Python 3.9.3 64 bit >> skips breakpoints
and
Python 3.9.2 64 bit >> works as expected
I have reproduced this multiple times just to ensure that I wasn't just solving a problem with a simple un-/reinstall.
I have raised an issue for this and I'll update this reply as soon as I find the proper root cause, but for now this solves the problem at my end...although not to my satisfaction.
https://github.com/microsoft/vscode-python/issues/15865
In 2024 with Python 3.11 this is still a problem with any code but yours (!) (defined by default justMyCode setting).
Solution is to add to your launch.json a separate configuration:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Python",
"type": "debugpy",
"request": "launch",
"justMyCode": false,
"program": "${file}",
},
... [rest of your file]
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