You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IndentationError when executing nested for-loops via “Run Selection/Line in Python Terminal” #26165
My script contains nested for loop structures. When executing the code line by line or cell by cell using the “Run Selection/Line in Python Terminal” feature in VS Code, it consistently raises an "IndentationError: unexpected indent".
Notably, this issue only started occurring after a recent update. Prior to the update, the same code and workflow executed without any errors.
I have tried the following solutions suggested on the VS Code forum, but the issue is still here:
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.
Python environment extension has been updated to the latest version. The "python.useEnvironmentsExtension": true has also been set in the settings.json.
However, the problem is still here after doing these.
VS Code version: Code 1.113.0 (Universal) (microsoft/vscode@cfbea10, 2026-03-24T15:07:18+01:00)
OS version: Darwin arm64 25.3.0
Modes:
System Info
Item
Value
CPUs
Apple M1 Pro (8 x 2400)
GPU Status
2d_canvas: enabledGPU0: VENDOR= 0x106b [Google Inc. (Apple)], DEVICE=0x0000 [ANGLE (Apple, ANGLE Metal Renderer: Apple M1 Pro, Version 26.3 (Build 25D125))], DRIVER_VENDOR=Apple, DRIVER_VERSION=26.3 ACTIVEMachine model name: MacBookProMachine model version: 18.3direct_rendering_display_compositor: disabled_off_okgpu_compositing: enabledmultiple_raster_threads: enabled_onopengl: enabled_onrasterization: enabledraw_draw: disabled_off_okskia_graphite: enabled_ontrees_in_viz: disabled_offvideo_decode: enabledvideo_encode: enabledwebgl: enabledwebgl2: enabledwebgpu: enabledwebnn: disabled_off
Thanks for the report. Run Selection/Line in Python Terminal is owned by the Python extension rather than the Python Environments extension. Please report this in microsoft/vscode-python with a minimal nested-loop example and the Python output-channel logs so that team can investigate it.
Activity
eleanorjboyd commentedon Sep 1, 2026
Thanks for the report. Run Selection/Line in Python Terminal is owned by the Python extension rather than the Python Environments extension. Please report this in microsoft/vscode-python with a minimal nested-loop example and the Python output-channel logs so that team can investigate it.