Debugger not hitting breakpoint when using a virtual environment
See original GitHub issueFrom @georgebridgeman on April 24, 2017 21:13
I cannot get the debugger to stop at breakpoints when my project is using a virtual environment created using the Python venv
module.
I have tried specifying the absolute path to Python in the pythonPath
property in launch.json
and launching VS Code from the command line, as suggested in issues #91 and #148 but still cannot get it to work.
The code in this example (a simple print statement) debugs fine when a project is not created in a venv.
Environment data
VS Code version: 1.11.2 Python Extension version: 0.6.3 Python Version: 3.6.0 OS and version: MacOS X 10.11.6
Actual behavior
Debugger runs and output is written to Debug Console, but breakpoints are not hit.
Expected behavior
Debugger should break on breakpoints.
Steps to reproduce:
cd ~/Projects
python3 -m venv TestVenv
cd TestVenv
source bin/activate
echo 'print("Hello, world!")' > test.py
code .
- Open
test.py
in the editor - Apply attached launch.json with absolute path to Python
- Switch back to
test.py
, add a breakpoint to line 1 and run debugger using F5 - Observe the output in Debug Console despite the breakpoint having no effect
Settings
Your launch.json (if dealing with debugger issues):
{
"version": "0.2.0",
"configurations": [
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "/Users/george/Projects/TestVenv/bin/python",
"program": "${file}",
"cwd": "${workspaceRoot}",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
}
]
}
Your settings.json:
No settings.json file in the project.
Logs
Output from Python
output panel
----------Generating Tags----------
ctags --options=/Users/george/.vscode/extensions/donjayamanne.python-0.6.3/resources/ctagOptions --languages=Python --exclude=**/site-packages/** -o /Users/george/Projects/TestVenv/.vscode/tags .
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ctags: illegal option -- -
usage: ctags [-BFadtuwvx] [-f tagsfile] file ...
Output from Console window
(Help->Developer Tools menu)
shell.ts:475TypeError: Cannot read property 'Threads' of null
at PythonDebugger.threadsRequest (/Users/george/.vscode/extensions/donjayamanne.python-0.6.3/out/client/debugger/Main.js:340:27)
at PythonDebugger.DebugSession.dispatchRequest (/Users/george/.vscode/extensions/donjayamanne.python-0.6.3/node_modules/vscode-debugadapter/lib/debugSession.js:427:22)
at PythonDebugger.ProtocolServer._handleData (/Users/george/.vscode/extensions/donjayamanne.python-0.6.3/node_modules/vscode-debugadapter/lib/protocol.js:104:38)
at Socket.<anonymous> (/Users/george/.vscode/extensions/donjayamanne.python-0.6.3/node_modules/vscode-debugadapter/lib/protocol.js:24:60)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at Pipe.onread (net.js:543:20): Error: TypeError: Cannot read property 'Threads' of null
at PythonDebugger.threadsRequest (/Users/george/.vscode/extensions/donjayamanne.python-0.6.3/out/client/debugger/Main.js:340:27)
at PythonDebugger.DebugSession.dispatchRequest (/Users/george/.vscode/extensions/donjayamanne.python-0.6.3/node_modules/vscode-debugadapter/lib/debugSession.js:427:22)
at PythonDebugger.ProtocolServer._handleData (/Users/george/.vscode/extensions/donjayamanne.python-0.6.3/node_modules/vscode-debugadapter/lib/protocol.js:104:38)
at Socket.<anonymous> (/Users/george/.vscode/extensions/donjayamanne.python-0.6.3/node_modules/vscode-debugadapter/lib/protocol.js:24:60)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at Pipe.onread (net.js:543:20)
at file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:2160295
at Object.v [as _notify] (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:50893)
at Object.enter (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:54394)
at _run (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:55715)
at _error (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:55232)
at file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:1911266
at g.e.dispatch (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:1912617)
at g.e.handleData (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:1912125)
at Socket.<anonymous> (file:////Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:28:1911126)
at emitOne (events.js:96:13)
Copied from original issue: DonJayamanne/pythonVSCode#913
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:20 (2 by maintainers)
Top GitHub Comments
@jonsagara Please could you try debugging using the new experimental debugger. Open your
launch.json
and change thetype
frompython
topythonExperimental
.@DerfelKadarn since we’re not switching the experimental debugger to be the default one until we’re happy with its stability we don’t have an ETA.