question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python debug mode not working properly

See original GitHub issue

Environment data

  • VS Code version: 1.55.2-1
  • Extension version (available under the Extensions sidebar): v2021.3.680753044
  • OS and version: 5.11.14-arch1-1
  • Python version: 3.9.3-1
  • Type of virtual environment used: N/A
  • Relevant/affected Python packages and their versions: debugpy (1.2.1)
  • Relevant/affected Python-related VS Code extensions and their versions: ms-python.python
  • Value of the python.languageServer setting: Pylance

Expected behaviour

If there are breakpoints or exceptions, when run in debug mode, application should be stopped and taken to breakpoints.

Actual behaviour

When run in debug mode the application doesn’t stop where it should.

Steps to reproduce:

  1. I’m running a minimal file with no other extensions enabled
print('foo')

def bar():
    print('bar')

raise Exception('raising exception!')

bar()
  1. I’m also using an autogenerated launch.json for the sake of simplicity
{
    // 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: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        }
    ]
}
  1. I set a breakpoint on the first line.

  2. Run file in debug mode.

image

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

foo
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/isinyaaa/.vscode/extensions/ms-python.python-2021.3.680753044/pythonFiles/lib/python/debugpy/__main__.py", line 45, in <module>
    cli.main()
  File "/home/isinyaaa/.vscode/extensions/ms-python.python-2021.3.680753044/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 444, in main
    run()
  File "/home/isinyaaa/.vscode/extensions/ms-python.python-2021.3.680753044/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 285, in run_file
    runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
  File "/usr/lib/python3.9/runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/isinyaaa/projects/test/test.py", line 6, in <module>
    raise Exception('raising exception!')
Exception: raising exception!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:8
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
yumashetacommented, Apr 18, 2021

I just realized that Python version 3.9.3 had a major bug: https://www.python.org/downloads/release/python-393/

So I built 3.9.4 from source and tested debugging. It now works. So it looks like the issue will be resolved as soon as 3.9.4 hits repositories…

can anyone else reproduce?

5reactions
grubelicommented, Apr 16, 2021

same here

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code Debugger not working for python - Microsoft Q&A
Debugging was working fine. Any troubleshooting tips. It seems when I do Run->"start Debugging' no command comes to terminal.
Read more >
Python debugger not working while normal run does
The python debugger in Pycharm (I've the latest version) is not working for any Python file (so it's not my project or anything)....
Read more >
Python debugging not working #18473 - GitHub
Debugger is not starting. It is just showed and disappear immediately. No error no message. At the same run button work as expected....
Read more >
Debugging Python program doesn't work after updating to VS ...
Click on the python extention (publisher microsoft) and select "install pre-release ". It would be V2022.5.10961002 (you can see it when you ...
Read more >
Debugging configurations for Python apps in Visual Studio Code
If you're only interested in debugging a Python script, the simplest way is to select the down-arrow next to the run button on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found