microsoft / microsoft/vscode-python-environments

IndentationError when executing nested for-loops via “Run Selection/Line in Python Terminal”

Abierto
#1,421 1 comentario 0 reacciones 1 asignado Ver en GitHub

@anthonykim1 ya está trabajando en esto.

Desde el 2/4/2026.

*out-of-scope
Lenguaje dominante
TypeScript
Estrellas
138
Forks
62
Merge medio
1 d 4 h
PR fusionados (30 d)
35

Descripción

Type: Bug

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:

Try install [https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-python-envs]
(https://url.au.m.mimecastprotect.com/s/lDwtC1WLjwsM2mD1XcLfnTVY9Qt?domain=marketplace.visualstudio.com)
- The Python environment has been installed.

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) (https://github.com/microsoft/vscode/commit/cfbea10c5ffb233ea9177d34726e6056e89913dc, 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
Load (avg) | 9, 9, 8
Memory (System) | 16.00GB (0.13GB free)
Process Argv | --crash-reporter-id 4ab29e73-b8f7-417a-a1ff-18cf979f4bc3
Screen Reader | no
VM | 0%

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.