Skip to content

Error refreshing packages: Extension uses system Python instead of selected Conda environment in WSL2 #653

@Shawn-Yangdr

Description

@Shawn-Yangdr

Type: Bug

Bug Description
When working in a WSL2 environment with a selected Conda virtual environment, the Python Environments extension fails to refresh the list of installed packages after pip install is used in the terminal.
The integrated terminal correctly activates the Conda environment upon launch. However, when pip install is run, a notification appears with the message "Error refreshing packages".
The logs indicate that the extension is attempting to run pip list using the system's default Python interpreter (/bin/python3), instead of the Python interpreter associated with the selected Conda environment (/home/shawn/anaconda3/envs/ELM/bin/python). This fails because the pip module is not available in the system's base Python installation.

Steps to Reproduce

  1. Set up a project in a WSL2 environment.
  2. Use the command palette to select a Conda environment as the Python interpreter (e.g., /home/shawn/anaconda3/envs/ELM/bin/python).
  3. Open a new integrated terminal. It should automatically activate the selected Conda environment.
  4. In the activated terminal, run pip install (for example, pip install requests).
  5. Observe the error notification shown in the screenshot below.

Expected Behavior
The extension should use the Python interpreter from the currently activated Conda environment to refresh the package list. It should execute a command similar to /home/shawn/anaconda3/envs/ELM/bin/python -m pip list, and the package list should refresh successfully without any errors.

Actual Behavior
An "Error refreshing packages" notification appears.
The logs show that the extension incorrectly calls the system's Python interpreter, causing the operation to fail.

Logs
[info] Using conda from cache: /home/shawn/anaconda3/condabin/conda
[info] "python-envs.terminal.autoActivationType" is set to "shellStartup", terminal should be activated by shell startup script
[info] Resolved Python Environment /home/shawn/anaconda3/envs/ELM/bin/python
[info] Using conda from cache: /home/shawn/anaconda3/condabin/conda
[info] Found named environment: /home/shawn/anaconda3/envs/ELM
[info] Running: /bin/python3 -m pip list
[info] python: /bin/python3: No module named pip
[error] Error refreshing packages Failed to run python -m pip list

The key issue is this line from the log: Running: /bin/python3 -m pip list. It should be using the path from the resolved environment.
Thank you for your time and assistance.

Extension version: 1.0.0
VS Code version: Code 1.102.2 (c306e94f98122556ca081f527b466015e1bc37b0, 2025-07-22T12:15:48.520Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 6.6.87.2-microsoft-standard-WSL2

System Info
Item Value
CPUs 12th Gen Intel(R) Core(TM) i5-12600KF (16 x 3686)
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) 31.82GB (14.34GB free)
Process Argv --crash-reporter-id dd0a523e-5015-4c26-b6f8-c259d1ece8e7
Screen Reader no
VM 20%
Item Value
Remote WSL: Ubuntu-20.04
OS Linux x64 6.6.87.2-microsoft-standard-WSL2
CPUs 12th Gen Intel(R) Core(TM) i5-12600KF (16 x 0)
Memory (System) 23.47GB (22.34GB free)
VM 0%
A/B Experiments
vsliv368cf:30146710
binariesv615:30325510
h48ei257:31000450
nativeloc1:31344060
dwcopilot:31170013
471b6256:31263136
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
pylancequickfixf:31350060
9d2cg352:31346308
usemarketplace:31343026
nesew2to5:31336538
agentclaude:31335814
nes-diff-11:31337487
replacestringexc:31350595
nes-set-on:31340697
6abeh943:31336334
envsdeactivate2:31353495
yijiwantestdri0626-c:31336931
0927b901:31350571
ji9b5146:31348712
0cj2b977:31352657

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugtriage-needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions