Open
Description
Configuring "console": "internalConsole"
for a launch target causes Python subprocesses spawned by the main debug process to not have their venv inherited correctly.
Repro. steps:
- Create a venv and install
cowsay
- Open VS Code in the venv parent dir
- Create files as follows:
test.py
:
import subprocess
stdout = subprocess.check_output(["python", "-m", "cowsay", "-t", "test"])
print(stdout.decode())
.vscode/launch.json
:
- Launch the debug target
Actual outcome
- Dialog box with "Server disconnected unexpectedly" displayed
- "No module named cowsay" printed in debug console
Expected outcome
- Subprocess runs without error
Notes
The underlying cause seems to be that the PATH
and VIRTUAL_ENV
env vars are not inherited correctly in spawned subprocesses when they are intercepted for debugging.