Skip to content

"Run Selection/Line in Python Terminal" results in "SyntaxError" #25678

@dharmatech

Description

@dharmatech

Type: Bug

Behaviour

Let's say I have the following in a python file:

print(123)

Move the cursor to that line.

Right click -> "Run Python" -> "Run Selection/Line in Python Terminal".

The terminal shows the following:

(uv-general-3.14) PS C:\Users\dharm\docs\sqlmodel-tutorial
> C:/Users/dharm/docs/sqlmodel-tutorial/.venv/Scripts/python.exe
Python 3.14.0 (tags/v3.14.0:ebf955d, Oct  7 2025, 10:15:03) [MSC v.1944 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Ctrl click to launch VS Code Native REPL
>>> 
KeyboardInterrupt
>>> & C:\Users\dharm\docs\sqlmodel-tutorial\.venv\Scripts\Activate.ps1
  File "<stdin>", line 1
    & C:\Users\dharm\docs\sqlmodel-tutorial\.venv\Scripts\Activate.ps1
    ^
SyntaxError: invalid syntax
>>> 

Screenshots

Image Image

Diagnostic data

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

2025-12-16 19:48:16.900 [info] > C:\Python314\python.exe ~\.vscode\extensions\ms-python.python-2025.20.0-win32-x64\python_files\normalizeSelection.py

Extension version: 2025.20.0
VS Code version: Code 1.107.0 (618725e67565b290ba4da6fe2d29f8fa1d4e3622, 2025-12-10T07:43:47.883Z)
OS version: Windows_NT x64 10.0.26200
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.14.0
  • 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
beancount Len 0.14.0
bqn-language raz 0.1.5
chatgpt ope 0.4.51
copilot-chat Git 0.35.0
csdevkit ms- 1.90.2
csharp ms- 2.110.4
debugpy ms- 2025.18.0
dotnet-interactive-vscode ms- 1.0.6323010
even-better-toml tam 0.21.2
fantomas-fmt pao 0.3.0
gemini-cli-vscode-ide-companion goo 0.20.0
gistfs vsl 0.9.5
html-preview-vscode geo 0.2.5
Ionide-fsharp Ion 7.30.0
jinjahtml sam 0.20.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
ledger mar 1.0.9
org-mode too 0.5.0
pine-script-syntax-highlighter ex- 1.0.5
powershell ms- 2025.4.0
python ms- 2025.20.0
rainbow-csv mec 3.23.0
remote-wsl ms- 0.104.3
tinymist myr 0.14.4
vscode-apache mrm 1.2.0
vscode-dotnet-runtime ms- 3.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-pylance ms- 2025.10.4
vscode-python-envs ms- 1.14.0
vscode-yaml red 1.19.1
System Info
Item Value
CPUs Intel(R) Core(TM) i9-10885H CPU @ 2.40GHz (16 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: 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) 63.72GB (36.99GB free)
Process Argv -n . --crash-reporter-id b6d73a27-f3ba-4196-9923-d0fd548cad16
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
pythonvspyt551:31249599
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31436602
aj953862:31281341
nes-set-on:31340697
6abeh943:31336334
envsactivate1:31353494
cloudbuttont:31379625
todos-1:31405332
3efgi100_wstrepl:31403338
trigger-command-fix:31379601
use-responses-api:31390855
anonusage:31403420
je187915:31401257
afag3459:31428711
ec5jj548:31422691
xtab-292:31432193
terminalsuggestenabled:31431119
cmp-ext-treat:31426748
cp_cls_c_966_ss:31435507
copilot6169-t2000-control:31431385
c0683394:31419495
478ah919:31426797
ge8j1254_inline_auto_hint_haiku:31431912
nes-undo-1:31426805
a5gib710:31434435
5j92g670_sonnet:31435823
request_with_suggest:31435827
rename_enabled:31436409
7a04d226_do_not_restore_last_panel_session:31434268
anthropic_thinking_t:31432745
preserve_tokens:31434536
cp_cls_c_1081:31433293
copilot-nes-oct-trt:31432596

Metadata

Metadata

Assignees

Labels

area-terminalbugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from poster

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions