Skip to content

Shift+enter to run Python: Run Selection/Line in Python Terminal not showing results immediately #25713

Open

Description

Type: Bug

Behaviour

While browsing .py in editor, hitting shift+enter should execute the line in the terminal and show results immediately.

Steps to reproduce:

  1. Create empty .py file
  2. Write a code
  3. Hit Shift + enter
  4. Line of code and execution result should be visible on the terminal

It was actually ran, and visible only after interacting with the interpreter.

Untitled.mov

Diagnostic data

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

XXX

Extension version: 2025.20.1
VS Code version: Code 1.107.1 (994fd12f8d3a5aa16f17d42c041e5809167e845a, 2025-12-17T14:15:14.850Z)
OS version: Darwin arm64 25.2.0
Modes:
Remote OS version: Linux x64 3.10.0-1160.2.1.el7.x86_64

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


languageServer: "Pylance"

Installed Extensions
Extension Name Extension Id Version
air-vscode Pos 0.18.0
copilot-chat Git 0.35.3
datawrangler ms- 1.24.0
debugpy ms- 2025.18.0
js-debug ms- 1.105.0
js-debug-companion ms- 1.1.3
jupyter ms- 2025.9.1
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.3.0
latex-workshop Jam 10.12.0
material-icon-theme PKi 5.30.0
python ms- 2025.20.1
python-ds-extension-pack ms- 0.0.1
quarto qua 1.127.0
r REd 2.8.6
r-syntax REd 0.1.3
rainbow-csv mec 3.23.0
remote-explorer ms- 0.5.0
remote-ssh ms- 0.122.0
remote-ssh-edit ms- 0.87.0
ruff cha 2025.32.0
theme-dracula dra 2.25.1
vscode-js-profile-table ms- 1.0.10
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
vscode-office cwe 3.5.4
vscode-peacock joh 4.2.2
vscode-pylance ms- 2025.10.4
vscode-theme-onedark aka 2.3.0
vsliveshare ms- 1.0.5959
System Info
Item Value
CPUs Apple M2 Max (12 x 2400)
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: enabled_on
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 2, 2, 2
Memory (System) 96.00GB (67.57GB free)
Process Argv --crash-reporter-id a0bf4440-e73d-41aa-a6c5-22a4017f6e8c
Screen Reader no
VM 0%
Item Value
Remote SSH: vscode-container
OS Linux x64 3.10.0-1160.2.1.el7.x86_64
CPUs AMD EPYC 7702 64-Core Processor (128 x 0)
Memory (System) 1007.41GB (885.50GB free)
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
defaultusage:31403421
ddidt:31399633
je187915:31401254
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
request_with_suggest:31435827
rename_enabled:31436409
7a04d226_do_not_restore_last_panel_session:31438103
anthropic_thinking_t:31432745
h0hdh950:31428394
cp_cls_c_1081:31433293
copilot-nes-oct-trt:31432596
nes-jump-on-with-edit:31442062
nes-slash-models-on:31441832
nes-set-to-on:31441941
a43f0576c:31442824

Activity

  1. changed the title [-]Shift+enter to run Python: Run Selection/Line in Python Terminal not working occasionally[/-] [+]Shift+enter to run Python: Run Selection/Line in Python Terminal not showing results immediately[/+] on Jan 6, 2026
  2. added
    bugIssue identified by VS Code Team member as probable bug
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on Jan 8, 2026
  3. anthonykim1 commented on Jan 8, 2026

    @anthonykim1

    Thank you for filing issue Matthew Son (@matthewgson)

    Does using environment extension help?
    Try install https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-python-envs

    Can you update Python extension, Python environment extension to latest and see if you can still repro?
    Also add "python.useEnvironmentsExtension": true, to your settings.json.

  4. matthewgson commented on Jan 8, 2026

    @matthewgson
    Author

    Thank you. Enabling the environment extension resolved the problem in my local vscode.

    However, I noticed that when I enable it in the remote ssh, it rather generates the problem above, somehow strangely.

  5. aleimba commented on Feb 25, 2026

    @aleimba

    Dear Anthony Kim (@anthonykim1) ,
    thank you for taking care of this issue.
    I have the same problem. Considering all the messages on GitHub/Stackoverflow etc. this seems to be a common and major problem.
    Since yesterday neither Shift+Enter nor command pallette 'Python: Run Selection/Line in Python Terminal' works for me in a Python script.

    I'm running:

    Version: 1.109.5
    Commit: 072586267e68ece9a47aa43f8c108e0dcbf44622
    Date: 2026-02-19T19:43:32.382Z
    Electron: 39.3.0
    ElectronBuildId: 13313481
    Chromium: 142.0.7444.265
    Node.js: 22.21.1
    V8: 14.2.231.22-electron.0
    OS: Linux x64 6.18.7-76061807-generic
    

    Following extensions installed and running:

    alefragnani.bookmarks-14.0.0
    charliermarsh.ruff-2026.36.0-linux-x64
    extensions.json
    george-alisson.html-preview-vscode-0.2.5
    github.copilot-chat-0.37.8
    gruntfuggly.todo-tree-0.0.226
    mads-hartmann.bash-ide-vscode-1.43.0
    mechatroner.rainbow-csv-3.24.1
    ms-python.debugpy-2025.18.0-linux-x64
    ms-python.python-2026.2.0-linux-x64
    ms-python.vscode-pylance-2026.1.1
    ms-python.vscode-python-envs-1.20.1-linux-x64
    ms-vscode.remote-explorer-0.5.0
    ms-vscode-remote.remote-ssh-0.122.0
    ms-vscode-remote.remote-ssh-edit-0.87.0
    oderwat.indent-rainbow-8.3.1
    phoihos.csv-to-md-table-0.3.1
    timonwong.shellcheck-0.38.8-linux-x64
    yzhang.markdown-all-in-one-3.6.3
    

    When I looked into the issue I saw that 'ms-python.vscode-python-envs-1.20.1-linux-x64' was updated yesterday, I guess this must be the problem ...
    However, changing to the pre-release version did not fix the issue. Also including "python.useEnvironmentsExtension": true, in my users setting JSON did not change anything...
    I currently use a workaround by using 'Terminal: Run Selected Text in Active Terminal' with a keyboard shortcut. But it doesn't have smartsend for code blocks etc.

    Do you have a suggestion how to fix this?
    Thanks a lot!

  6. anthonykim1 commented on Mar 2, 2026

    @anthonykim1

    Matthew Son (@matthewgson) Andreas Leimbach (@aleimba) When environment extension is enabled, do you see the proper interpreter selected in the environment extension panel?

    Image

    Also please be on latest PRE-release of the environment extension as there were bunch of fixes there.
    If that doesnt work please set the log level to trace and paste the output from Python and Python environments channel !

    Thank you all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-terminalbugIssue identified by VS Code Team member as probable bugconfirmation pendingThe issue needs to be confirmed through a maintainer reproducing the bug.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions