Skip to content

Unexpected Execution of KeyboardInterrupt when First Run A Code that Can Block Task #25720

@HeavanDine

Description

@HeavanDine

Type: Bug

Description
When running Python code that requires blocking input (e.g., input()) for the first time in a new shell, VS Code triggers an unexpected KeyboardInterrupt.
This issue only occurs inside a Python virtual environment (venv).
Running the same code a second time (and any subsequent times) works normally.

This behavior does not occur when using the system Python interpreter.
I am using the default "python" debug configuration provided by VS Code.

Steps to Reproduce

  1. Open VS Code.

  2. Create or activate a Python venv.

  3. Run a simple blocking script, for example:

input("Enter something: ")

  1. Observe that VS Code immediately raises a KeyboardInterrupt on the first run.

  2. Run the same script again in the same shell.

  3. The script works normally without interruption.

Expected Behavior
The script should wait for user input normally on the first run, just like it does on subsequent runs.

Actual Behavior

Image

On the first execution in a new shell:

The program is interrupted automatically.

A KeyboardInterrupt is raised without any user action.

On second and later executions:

The script behaves normally and waits for input.

Additional Notes
The issue only appears when using a virtual environment.

The issue does not occur with the system Python interpreter.

I am using the default "python" launch configuration generated by VS Code.

ScreenShot_2026-01-09_04-46-44.mp4

Environment:

VS Code version: 1.108.0

Python extension version: 2025.21.2026010601

Operating System: Windows 11 25H2 26200.7462

Python version: python 3.14.2

Virtual environment type: venv

Shell used: PowerShell

Extension version: 2025.21.2026010601
VS Code version: Code 1.108.0 (94e8ae2b28cb5cc932b86e1070569c4463565c37, 2026-01-08T13:53:10.781Z)
OS version: Windows_NT x64 10.0.26200
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.14.2
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): System
  • Value of the python.languageServer setting: Default
User Settings


languageServer: "Pylance"

Installed Extensions
Extension Name Extension Id Version
autodocstring njp 0.6.1
copilot-chat Git 0.35.3
debugpy ms- 2025.19.2025121701
even-better-toml tam 0.21.2
js-debug ms- 1.105.0
js-debug-companion ms- 1.1.3
jupyter ms- 2025.10.2026010601
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.3.2025062701
python ms- 2025.21.2026010601
remote-containers ms- 0.438.0
remote-explorer ms- 0.5.0
remote-server ms- 1.5.3
remote-ssh ms- 0.122.0
remote-ssh-edit ms- 0.87.0
remote-wsl ms- 0.104.3
ruff cha 2026.34.0
vscode-docker ms- 2.0.0
vscode-js-profile-table ms- 1.0.10
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
vscode-language-pack-zh-hans MS- 1.108.2026010709
vscode-pylance ms- 2025.10.100
vscode-python-envs ms- 1.15.13521015
vscode-remote-extensionpack ms- 0.26.0
System Info
Item Value
CPUs 13th Gen Intel(R) Core(TM) i7-13650HX (20 x 2803)
GPU Status 2d_canvas: enabled
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 31.63GB (18.07GB free)
Process Argv --crash-reporter-id 57e8a3cf-b24b-44a7-a2da-975ff851ba3d
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31436602
aj953862:31281341
6abeh943:31336334
envsactivate1:31353494
cloudbuttont:31379625
3efgi100_wstrepl:31403338
use-responses-api:31390855
je187915:31407605
ec5jj548:31422691
terminalsuggestenabled:31431119
cmp-ext-treat:31426748
cp_cls_c_966_ss:31442353
c0683394:31419495
478ah919:31426797
ge8j1254_inline_auto_hint_haiku:31427726
a5gib710:31434435
38bie571_auto:31426784
no_request_with_suggest:31435826
rename_enabled:31436409
7a04d226_do_not_restore_last_panel_session:31438103
anthropic_thinking_t:31432745
h0hdh950:31428394
cp_cls_c_1081:31443829
copilot-nes-callisto-trt:31434412
nowdiget:31442216
nes-slash-models-on:31441832
nes-set-to-on:31441941
a43f0576c:31442824

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-neededNeeds assignment to the proper sub-team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions