Skip to content

Code debugging starts before conda env activatesΒ #25329

@Sunlight-zero

Description

@Sunlight-zero

Type: Bug

Behaviour

When trying to debug a .py file in conda environment on Windows 11, the debugger runs the python file before conda activate <env>.

In detail, there are two conda activating commands that the Python extension will automatically run:

<conda env path>/Scripts/activate
conda activate <env name>

But when debugging a Python code, the debugger starts after <conda env path>/Scripts/activate but before conda activate <env name>, which may cause some incorrect environment settings, like a wrong PATH and cannot find dynamic link libraries.

Steps to reproduce:

  1. Ensure conda has been installed.
  2. Select a conda environment's python exe as the python interpreter for .py
  3. Debug a .py file.

Diagnostic data

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

PS D:\program\Python\auto-workflows> D:/program/Python/anaconda/envs/math_model/Scripts/activate
PS D:\program\Python\auto-workflows>  & 'd:\program\Python\anaconda\envs\workflow\python.exe' 'c:\Users\Sunlight\.vscode\extensions\ms-python.debugpy-2025.10.0-win32-x64\bundled\libs\debugpy\launcher' '8419' '--' 'd:\program\Python\auto-workflows\helloworld.py' 
Hello World
PS D:\program\Python\auto-workflows> conda activate workflow
(workflow) PS D:\program\Python\auto-workflows> 

Extension version: 2025.11.2025072501
VS Code version: Code 1.102.2 (c306e94f98122556ca081f527b466015e1bc37b0, 2025-07-22T12:15:48.520Z)
OS version: Windows_NT x64 10.0.26100
Modes:

System Info
Item Value
CPUs 12th Gen Intel(R) Core(TM) i7-12700H (20 x 2688)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.63GB (3.50GB free)
Process Argv --crash-reporter-id 59651958-9740-4efc-af64-7724da49518f
Screen Reader no
VM 50%
A/B Experiments
vsliv368cf:30146710
pythonvspyt551:31249599
binariesv615:30325510
2e7ec940:31000449
nativeloc1:31344060
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
hdaa2157:31222309
copilot_t_ci:31333650
e5gg6876:31282496
pythoneinst12:31285622
c7cif404:31314491
pythonpulldiag:31343502
996jf627:31283433
pythonrdcb7:31342333
usemplatestapi:31297334
0aa6g176:31307128
747dc170:31275177
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003
pylancequickfixt:31350061
9d2cg352:31346308
convertlamdat:31350063
usemarketplace:31343026
nesew2to5:31336538
agentclaude:31350858
nes-diff-11:31337487
replacestringexc:31350595
nes-set-on:31351930
testaa123:31335226
6abeh943:31336334
yijiwantestdri0626-t:31336930
0927b901:31350571
ji9b5146:31348712
0cj2b977:31352657
0574c672:31355360

Metadata

Metadata

Assignees

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