Type: Bug Behavior When using VS Code connected to WSL, there is a race condition between the Python extension's environment activation and the Code Runner extension's execution command. When attempting to run a Python script using Code Runner ("Run Code"), the command executes in the terminal before the Python extension has finished activating the selected Conda environment. This causes the script to run in the default base environment, leading to a ModuleNotFoundError for any packages specific to the selected environment. The expected behavior is for the terminal to wait for the conda activate command to complete before executing the script, ensuring it runs in the correct, fully activated environment. Steps to reproduce: Setup the Environment: OS: Windows 11 with WSL 2 (Ubuntu). Software: Miniconda installed inside WSL. VS Code with the official Microsoft Python, WSL, and Code Runner extensions. Conda Environments: base (default, does not have pandas) test (created with conda create -n test python=3.9 pandas) Project File (test.py): import pandas as pd print("Executed correctly") Connect to WSL: Open the project folder in VS Code using the WSL-Remote connection. Select Interpreter: Use the Command Palette (Ctrl+Shift+P) to run Python: Select Interpreter and choose the Python interpreter from the test Conda environment. The status bar should correctly show ('test': conda). Run with Code Runner: With test.py open, right-click and select "Run Code". Observe the Failure: The terminal will show the script failing with ModuleNotFoundError: No module named 'pandas', followed by the delayed conda activate test command executing after the failure. Successful Workaround & Analysis for Diagnosis This information helps diagnose the issue: Working Method: The bug is avoided by using the Python extension's native "Run Python File" feature (the triangular play button). Reasoning: This method works because it calls the interpreter by its full, explicit path (/home/aadarsh/miniconda3/envs/test/bin/python), which does not depend on the shell's activation state. This confirms the issue is with the timing of shell activation for external extensions like Code Runner. Issue with it: This method work but is not the complete solution as it do not flush the output after shell activation like it does in windows. Diagnostic data Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python) 2025-07-20 19:13:36.882 [info] Experiment 'pythonTerminalEnvVarActivationcf' is active 2025-07-20 19:13:36.882 [info] Native locator: Refresh started 2025-07-20 19:13:36.882 [info] > pyenv which python 2025-07-20 19:13:36.882 [info] cwd: ~/College/Deep Learning/test 2025-07-20 19:13:38.247 [info] > conda info --json 2025-07-20 19:13:38.318 [info] Conda environment manager found at: /home/aadarsh/miniconda3/bin/conda 2025-07-20 19:13:38.318 [info] Using conda: /home/aadarsh/miniconda3/bin/conda 2025-07-20 19:13:38.821 [info] > ~/miniconda3/bin/conda info --json 2025-07-20 19:13:38.901 [info] Native locator: Refresh finished in 8308 ms 2025-07-20 19:13:42.238 [info] Python interpreter path: ~/miniconda3/envs/tensor/bin/python 2025-07-20 19:13:42.588 [info] Send text to terminal: conda activate tensor 2025-07-20 19:13:44.847 [info] Starting Pylance language server. 2025-07-20 19:15:03.855 [info] Discover tests for workspace name: undefined - uri: c:/Users/aadar/AppData/Roaming/Code/User/profiles/5dd44f91/settings.json 2025-07-20 19:15:10.781 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:15:11.788 [info] Native locator: Refresh started 2025-07-20 19:15:11.818 [info] Conda environment manager found at: /home/aadarsh/miniconda3/bin/conda 2025-07-20 19:15:11.818 [info] Conda set to: /home/aadarsh/miniconda3/bin/conda 2025-07-20 19:15:17.198 [info] Native locator: Refresh finished in 5410 ms 2025-07-20 19:15:17.435 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:15:20.282 [info] > ~/miniconda3/bin/conda info --json 2025-07-20 19:15:23.876 [info] Send text to terminal: conda activate tensor 2025-07-20 19:16:04.267 [info] Native locator: Refresh started 2025-07-20 19:16:04.288 [info] Conda environment manager found at: /home/aadarsh/miniconda3/bin/conda 2025-07-20 19:16:04.288 [info] Conda set to: /home/aadarsh/miniconda3/bin/conda 2025-07-20 19:16:05.558 [info] Active interpreter [/home/aadarsh/College/Deep Learning/test]: /home/aadarsh/miniconda3/envs/test/bin/python 2025-07-20 19:16:05.589 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test 2025-07-20 19:16:05.589 [info] Python interpreter path: ~/miniconda3/envs/test/bin/python 2025-07-20 19:16:06.641 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:16:07.769 [info] Send text to terminal: conda activate test 2025-07-20 19:16:10.715 [info] Native locator: Refresh finished in 6448 ms 2025-07-20 19:16:10.716 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test 2025-07-20 19:16:40.886 [info] Discover tests for workspace name: undefined - uri: c:/Users/aadar/AppData/Roaming/Code/User/profiles/5dd44f91/settings.json 2025-07-20 19:17:22.348 [info] > ~/miniconda3/bin/conda info --json 2025-07-20 19:17:25.783 [info] Send text to terminal: conda activate test 2025-07-20 19:17:55.240 [info] Discover tests for workspace name: undefined - uri: c:/Users/aadar/AppData/Roaming/Code/User/profiles/5dd44f91/settings.json 2025-07-20 19:17:58.022 [info] Discover tests for workspace name: undefined - uri: c:/Users/aadar/AppData/Roaming/Code/User/profiles/5dd44f91/settings.json 2025-07-20 19:29:05.816 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:29:10.597 [info] > ~/miniconda3/bin/conda info --json 2025-07-20 19:29:15.191 [info] Send text to terminal: conda activate test 2025-07-20 19:29:16.000 [info] Send text to terminal: conda activate test 2025-07-20 19:29:16.124 [info] CreateEnv Trigger - Skipping for /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:29:17.015 [info] Send text to terminal: /home/aadarsh/miniconda3/envs/test/bin/python "/home/aadarsh/College/Deep Learning/test/test.py" 2025-07-20 19:29:29.780 [info] Send text to terminal: conda activate test 2025-07-20 19:29:30.783 [info] Send text to terminal: /home/aadarsh/miniconda3/envs/test/bin/python "/home/aadarsh/College/Deep Learning/test/test.py" 2025-07-20 19:29:40.144 [info] Send text to terminal: conda activate test 2025-07-20 19:29:40.749 [info] Send text to terminal: /usr/bin/env /home/aadarsh/miniconda3/envs/test/bin/python /home/aadarsh/.vscode-server/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 46429 -- /home/aadarsh/College/Deep\ Learning/test/test.py 2025-07-20 19:36:45.910 [info] > ~/miniconda3/bin/conda info --json 2025-07-20 19:36:49.832 [info] Send text to terminal: conda activate test 2025-07-20 19:36:56.225 [info] Send text to terminal: conda activate test 2025-07-20 19:44:56.569 [info] > ~/miniconda3/bin/conda info --json 2025-07-20 19:45:00.470 [info] Send text to terminal: conda activate test 2025-07-20 19:45:12.209 [info] Send text to terminal: python -u "/home/aadarsh/College/Deep Learning/test/test.py" 2025-07-20 19:45:36.930 [info] Send text to terminal: conda activate test 2025-07-20 19:45:37.431 [info] Send text to terminal: /home/aadarsh/miniconda3/envs/test/bin/python "/home/aadarsh/College/Deep Learning/test/test.py" 2025-07-20 19:45:58.953 [info] Send text to terminal: conda activate test 2025-07-20 19:45:59.454 [info] Send text to terminal: /home/aadarsh/miniconda3/envs/test/bin/python "/home/aadarsh/College/Deep Learning/test/test.py" 2025-07-20 19:47:01.151 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:11.107 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:14.156 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:15.233 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:19.835 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:21.939 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:23.481 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:26.861 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:27.777 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:28.905 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:33.049 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:41.035 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:46.130 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:48.338 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:47:55.716 [info] Discover tests for workspace name: test - uri: /home/aadarsh/College/Deep Learning/test/test.py 2025-07-20 19:48:16.680 [info] > ~/miniconda3/bin/conda info --json 2025-07-20 19:48:18.002 [info] Send text to terminal: /home/aadarsh/miniconda3/envs/test/bin/python "/home/aadarsh/College/Deep Learning/test/test.py" 2025-07-20 19:48:21.414 [info] Send text to terminal: conda activate test 2025-07-20 19:48:30.535 [info] Send text to terminal: conda activate test 2025-07-20 19:48:37.951 [info] Send text to terminal: conda activate test 2025-07-20 19:48:38.452 [info] Send text to terminal: /home/aadarsh/miniconda3/envs/test/bin/python "/home/aadarsh/College/Deep Learning/test/test.py" 2025-07-20 20:02:52.035 [info] > ~/miniconda3/bin/conda info --json 2025-07-20 20:02:55.274 [info] Send text to terminal: conda activate test Extension version: 2025.10.0 VS Code version: Code 1.102.1 (7adae6a56e34cb64d08899664b814cf620465925, 2025-07-15T16:41:17.147Z) OS version: Windows_NT x64 10.0.26100 Modes: Remote OS version: Linux x64 6.6.87.2-microsoft-standard-WSL2 - Python version (& distribution if applicable, e.g. Anaconda): 3.11.13 - Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda - Value of the `python.languageServer` setting: Default User Settings ``` languageServer: "Pylance" ``` Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |autodocstring|njp|0.6.1| |black-formatter|ms-|2025.2.0| |cmake-tools|ms-|1.21.36| |code-runner|for|0.12.2| |code-spell-checker|str|4.0.47| |codesnap|adp|1.3.4| |copilot|Git|1.344.0| |copilot-chat|Git|0.29.1| |cpptools|ms-|1.26.3| |cpptools-extension-pack|ms-|1.3.1| |datawrangler|ms-|1.22.0| |debugpy|ms-|2025.10.0| |hexeditor|ms-|1.11.1| |indent-rainbow|ode|8.3.1| |intellicode-api-usage-examples|Vis|0.2.9| |js-debug|ms-|1.102.0| |jupyter|ms-|2025.6.0| |jupyter-hub|ms-|2024.5.1002432242| |jupyter-renderers|ms-|1.3.0| |LiveServer|rit|5.7.9| |powershell|ms-|2025.2.0| |pylint|ms-|2025.2.0| |python|ms-|2025.10.0| |rainbow-csv|mec|3.20.0| |randomeverything|hel|0.0.3| |vscode-js-profile-table|ms-|1.0.10| |vscode-jupyter-cell-tags|ms-|0.1.9| |vscode-jupyter-slideshow|ms-|0.1.6| |vscode-pets|ton|1.32.0| |vscode-pylance|ms-|2025.6.2| |vscodeintellicode|Vis|1.3.2| System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 7 8845HS w/ Radeon 780M Graphics (16 x 3793)| |GPU Status|2d_canvas: enabledcanvas_oop_rasterization: enabled_ondirect_rendering_display_compositor: disabled_off_okgpu_compositing: enabledmultiple_raster_threads: enabled_onopengl: enabled_onrasterization: enabledraw_draw: disabled_off_okskia_graphite: disabled_offvideo_decode: enabledvideo_encode: enabledvulkan: disabled_offwebgl: enabledwebgl2: enabledwebgpu: enabledwebnn: disabled_off| |Load (avg)|undefined| |Memory (System)|15.31GB (1.92GB free)| |Process Argv|--crash-reporter-id a0e5e44a-26c1-4205-999f-a9cc6a5a9543| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|WSL: Ubuntu-24.04| |OS|Linux x64 6.6.87.2-microsoft-standard-WSL2| |CPUs|AMD Ryzen 7 8845HS w/ Radeon 780M Graphics (16 x 0)| |Memory (System)|7.41GB (0.30GB free)| |VM|0%| A/B Experiments ``` vsliv368:30146709 binariesv615:30325510 0bi6i642:31350688 h48ei257:31000450 nativeloc1:31344060 5fd0e150:31155592 dwcopilot:31170013 6074i472:31201624 dwoutputs:31242946 9064b325:31222308 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 usemarketplace:31343026 nesew2to5:31336538 agentclaude:31350861 4f60g487:31327383 nes-diff-11:31337487 replacestringexc:31350595 nes-set-on:31350020 testaa123:31335226 6abeh943:31336334 yijiwantestdri0626-c:31336931 0927b901:31350571 f76d9909:31348711 nes-deb-00:31346719 0cj2b977:31350606 1c1c4419-mono:31350621 ```