Skip to content

Code debugging starts before conda env activates #895

Closed as not planned
Closed as not planned

Description

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

Activity

  1. yonatan-rozenek commented on Jul 28, 2025

    @yonatan-rozenek

    I experience a similar issue on linux which causes the debugger to sometimes run before my .zshrc file. This file also contains my conda init logic and therefore causes similar issue.

  2. eleanorjboyd commented on Aug 4, 2025

    @eleanorjboyd
    Member

    Hi! Can you check to see if the behavior changes if you disable the "Python Environments Extension?"?

  3. yonatan-rozenek commented on Aug 5, 2025

    @yonatan-rozenek

    TL;DR Disabling the Powerlevel10k Instant Prompt feature resolved the issue for me.

    In my case, the issue was caused by the Instant Prompt feature of Powerlevel10k. It seems that this feature caused my .zshrc to execute in a non-blocking way, allowing subsequent Zsh commands (such as debugging) to run before it finished. I also noticed that sometimes the conda environment attempted to activate before the .zshrc init code had fully run, which also led me to suspect that my .zshrc wasn’t blocking as expected.

  4. Sunlight-zero commented on Aug 5, 2025

    @Sunlight-zero
    Author

    Hi! Can you check to see if the behavior changes if you disable the "Python Environments Extension?"?

    No. After disabling Python Environments Extension, the problem still exists.

    PS D:\program\Python\auto-workflows> D:/program/Python/miniconda/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' '8663' '--' '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> 
    
  5. eleanorjboyd commented on Aug 13, 2025

    @eleanorjboyd
    Member

    Sunlight Zero (@Sunlight-zero) are you using something similar to @yonaroz like Powerlevel10k Instant Prompt?

    cc Anthony Kim (@anthonykim1)

  6. Sunlight-zero commented on Aug 15, 2025

    @Sunlight-zero
    Author

    Eleanor Boyd (@eleanorjboyd) I have disabled or uninstalled all other plugins and left Python and Python Debugger only, but the problem still exists.

    Image
    PS D:\program\Python\auto-workflows> D:/program/Python/miniconda/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' '2612' '--' '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>
  7. eleanorjboyd commented on Dec 12, 2025

    @eleanorjboyd
    Member

    Hi! Are people still experiencing this issue?

  8. vs-code-engineering commented on Dec 20, 2025

    @vs-code-engineering

    This issue has been closed as it has been labeled with info-needed and has not received the additional information that was requested from the issue author. It has been labeled as info-needed for 7 days.

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

Metadata

Metadata

Labels

info-neededIssue requires more information from postertriage-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