Visitar URL original
Python extension fails to select Conda/Anaconda environment ("Invalid Python interpreter" & t.runInTerminal error) · Issue #26087 · microsoft/vscode-python · GitHub
Skip to content

Python extension fails to select Conda/Anaconda environment ("Invalid Python interpreter" & t.runInTerminal error) #26087

Description

@abtxph01

Type: Bug

Behaviour

Selecting any Anaconda/Conda environment (whether base or a custom environment) via Python: Select Interpreter fails.

VS Code displays:

"An Invalid Python interpreter is selected, please try changing it to enable features such as IntelliSense, linting, and debugging."

The status bar remains yellow ("No Python environment is set for this resource"), and execution fails due to an internal t.runInTerminal error.


Steps to Reproduce

  1. Install Anaconda on Windows 11 under C:\Users\<username>\anaconda3.
  2. Open VS Code and open a .py file.
  3. Open Command Palette (Ctrl+Shift+P) -> Python: Select Interpreter.
  4. Select either the base or custom Conda environment.

Expected Result

VS Code binds the selected Python interpreter to the current workspace.

Actual Result

Selection is rejected with the "Invalid Python interpreter" error, and the terminal log shows a t.runInTerminal argument failure.


Diagnostics Verified

  • Binary execution via external PowerShell (& "C:\Users\<username>\anaconda3\envs\CondaEnv\python.exe" --version) succeeds (Python 3.13.14).
  • Running VS Code as Administrator does not resolve the issue.
  • Cleared %APPDATA%\Code\User\globalStorage and workspaceStorage.
  • Switched default terminal profile to PowerShell and set python.terminal.activateEnvironment: false.

Output Log (Python Channel)

2026-08-01 20:16:07.284 [info] Native locator: Refresh started
2026-08-01 20:16:07.944 [info] Native locator: Refresh finished in 660 ms
2026-08-01 20:16:09.006 [info] Starting Pylance language server.
2026-08-01 20:16:09.022 [info] > python -c "import sys;print(sys.executable)"
2026-08-01 20:16:11.692 [info] Active interpreter [global]:  c:\Users\pabt1\anaconda3\envs\CondaEnv\python.exe
2026-08-01 20:16:11.842 [info] Active interpreter [global]:  python
2026-08-01 20:21:35.996 [error] Failed to execute file in terminal [Error: Invalid arguments to run in terminal
    at t.runInTerminal (c:\Users\pabt1\.vscode\extensions\ms-python.python-2026.0.0-win32-x64\out\client\extension.js:2:457813)
    at async P.executeUsingExtension (c:\Users\pabt1\.vscode\extensions\ms-python.python-2026.0.0-win32-x64\out\client\extension.js:2:878460)
    at async c:\Users\pabt1\.vscode\extensions\ms-python.python-2026.0.0-win32-x64\out\client\extension.js:2:875685
    at async jg._executeContributedCommand (file:///c:/Users/pabt1/AppData/Local/Programs/Microsoft%20VS%20Code/e4c7e7b1d6/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:535:48807)]
2026-08-01 20:21:39.496 [info] Active interpreter [global]:  c:\Users\pabt1\anaconda3\envs\CondaEnv\python.exe
2026-08-01 20:21:39.592 [info] Active interpreter [global]:  python

Extension version: 2026.0.0
VS Code version: Code 1.131.0 (e4c7e7b1d6d060162f4aa7f8225271b67ce1df75, 2026-07-28T10:51:25Z)
OS version: Windows_NT x64 10.0.26200
Modes:

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|AMD Ryzen 7 5800H with Radeon Graphics          (16 x 3194)|
|GPU Status|2d_canvas: enabled<br>GPU0: VENDOR= 0x10de, DEVICE=0x2560 [NVIDIA GeForce RTX 3060 Laptop GPU], DRIVER_VENDOR=NVIDIA, DRIVER_VERSION=32.0.16.1088 *ACTIVE*<br>GPU1: VENDOR= 0x1002, DEVICE=0x1638 [AMD Radeon(TM) Graphics], DRIVER_VERSION=31.0.12044.3<br>GPU2: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VERSION=10.0.26100.8875<br>Machine model name: <br>Machine model version: <br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>skia_graphite: disabled_off<br>trees_in_viz: disabled_off<br>video_decode: enabled<br>video_encode: enabled<br>webgl: enabled<br>webgpu: enabled<br>webnn: disabled_off|
|Load (avg)|undefined|
|Memory (System)|13.86GB (2.70GB free)|
|Process Argv|--crash-reporter-id 4d8622fe-b93c-46a6-ba34-3a5b0542e64b|
|Screen Reader|no|
|VM|0%|
</details><details>
<summary>A/B Experiments</summary>

vsliv368:30146709
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31463988
aj953862:31281341
4f60g487:31327383
envsactivate1:31551504
gh487529:31544284
cloudbuttont:31379625
42190218_ostrepl:31403339
ddidtcf:31399634
ec5jj548:31422691
cp_cls_t_966_ss:31526232
4je02754:31466945
8hhj4413:31478653
cp_cls_t_1081:31454832
conptydll_true:31498968
e9c30283:31461165
test_treatment2:31471001
46204921:31447328
control_6dc23131:31555649
idci7584:31464702
e3e4d672:31494082
ei9d7968:31496641
nes-extended-on:31455476
chat:31457767
8hig5102:31480529
89g7j272:31518289
7e187181:31503455
i2gc6536:31499202
52612955:31516516
ghj88844:31499326
ddid_c:31478207
hmra_i5g22:31518061
7df3h592:31512476
cp_cls_t_1082:31535311
logging_enabled_new:31498466
j0d79568:31499440
jb_cp_cls_t_632:31543129
56dj4588:31512888
32d76977:31512328
ha629193:31508444
cdk-lw-on:31524445
f9bf7985:31543584
jh5f2457_c:31540921
41836166:31537719
jbcp_cls_pctr_t:31531130
61138546:31518536
cp_intellij_t_nes:31548657
d7b18187:31526828
nes-curr-leftover-1500:31538366
ahp-both-windows:31556933
h561g132:31533256
session_8:31532895
ihg5j128:31534457
f412h606:31551416
7g2b5551:31542111
max-result-100:31551154
nes-ex-cf-euporie-03:31542868
5fe6f778:31554331
allow-none:31555437
6i51c363:31551401
c7c27ce7:31554789
nes-gb3-nf-6k:31554346
8hc4g144:31558143
0dg73464:31554319
treatment-23-1:31555779
unuse_dynamic_mcp:31555281
session-mark-done:31558131


</details>

<!-- generated by issue reporter -->

Activity

  1. abtxph01 commented on Aug 1, 2026

    @abtxph01
    Author

    I reported this initially on StackOverflow. See this post here with the steps I tried to solve it:
    https://stackoverflow.com/questions/79989245/vs-code-python-extension-fails-to-set-anaconda-base-interpreter-invalid-python

  2. abtxph01 commented on Aug 1, 2026

    @abtxph01
    Author

    Hi Eleanor Boyd (@eleanorjboyd),

    Sorry for opening this in vscode-python again—I saw your feedback on my Q&A for this issue too late!

    Here are the requested diagnostics and additional findings for this bug:

    1. Python Environments Extension Version: v1.36.0
    2. Key Finding (Folder vs. No-Folder):
      • Opening the enclosing folder as a workspace (e.g. Downloads folder): Selection works fine and code executes without issues.
      • Opening the exact same .py file standalone (no-folder window): Selection fails with "An Invalid Python interpreter is selected..." and the status bar remains yellow with "Select Python Interpreter".

    PET Output (pet find --verbose):

    PS C:\Users<username>> & c:\Users<username>.vscode\extensions\ms-python.vscode-python-envs-1.36.0-win32-x64\python-env-tools\bin\pet.exe find --verbose
    0.003151400s WARN pet_windows_registry::environments: Failed to open HKLM\Software\Python, Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }
    0.004807500s WARN pet_conda::package: Unable to find conda package Conda in "C:\Users\\anaconda3", trying slower approach
    0.010509600s WARN pet_conda::package: Unable to find conda package Python in "C:\Users\\anaconda3", trying slower approach
    0.012874500s WARN pet_conda::package: Unable to find conda package Conda in "C:\Users\\anaconda3", trying slower approach
    0.013128900s WARN pet_windows_registry::environments: Failed to open HKLM\Software\Python, Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }
    0.014925300s WARN pet_conda::package: Unable to find conda package Conda in "C:\Users\\anaconda3", trying slower approach
    0.081026100s WARN pet_conda::package: Unable to find conda package Python in "C:\Users\\anaconda3", trying slower approach

    Breakdown by each locator:

    Conda : 79.3494ms
    Hatch : 708.4µs
    PipEnv : 747.5µs
    Pixi : 200ns
    Poetry : 1.5536ms
    PyEnv : 708.8µs
    Uv : 293.1µs
    Venv : 100ns
    VirtualEnv : 1.4µs
    VirtualEnvWrapper : 100ns
    WinPython : 86.8µs
    WindowsRegistry : 13.6803ms
    WindowsStore : 270.1µs

    Breakdown for finding Environments:

    GlobalVirtualEnvs : 5.7777ms
    Locators : 79.9531ms
    Path : 6.5126ms
    Workspaces : 21.6089ms

    Environment Paths:

    Conda:

    • C:\Users<username>\anaconda3\python.exe
    • C:\Users<username>\anaconda3\envs\CondaEnv\python.exe

    Managers:

    Conda : 1

    Environments (2):

    Conda : 2

    Completed in 84ms

  3. hugo-jz commented on Aug 14, 2026

    @hugo-jz

    I have the same exact issue after a fresh Anaconda and VS Code install. Is there a fix/workaround yet?

  4. Matsunhong commented on Aug 19, 2026

    @Matsunhong

    I encountered a very similar “Invalid Python interpreter” issue on Windows, but in my case the root cause turned out to be broken ACL inheritance in an All Users Anaconda installation under C:\ProgramData\Anaconda3.

    Environment

    • VS Code 1.133.0 (User Setup)
    • Reproduced with Python extension 2026.4.0 and 2025.16.0
    • Anaconda installed at C:\ProgramData\Anaconda3
    • Conda environments stored under C:\Users\<username>\.conda\envs

    Symptoms

    • VS Code could discover the Conda environments.
    • Selecting an environment showed the correct interpreter path in the Python output log, but VS Code still reported “Invalid Python interpreter”.
    • The environment python.exe files themselves worked correctly when launched directly.
    • Running VS Code as Administrator completely fixed the problem and allowed switching between all Conda environments.

    That last point led me to check Conda's filesystem permissions. From a normal (non-elevated) Command Prompt:

    "C:\ProgramData\Anaconda3\Scripts\conda.exe" --version
    
    initially returned:
    
    Access is denied.
    
    icacls showed that conda.exe did not inherit the normal BUILTIN\Users:(RX) permission. It only had entries such as:
    
    BUILTIN\Administrators:(F)
    NT AUTHORITY\SYSTEM:(F)
    NT AUTHORITY\LogonSessionId_...:(RX)
    
    After re-enabling inheritance on conda.exe, the error moved to conda-script.py. After fixing that, it moved again to:
    
    C:\ProgramData\Anaconda3\lib\site-packages\conda\__init__.py
    PermissionError: [Errno 13] Permission denied
    
    So this was not a single-file problem; ACL inheritance was broken across multiple files in the Anaconda installation.
    
    I backed up the ACLs and recursively re-enabled inheritance:
    
    icacls "C:\ProgramData\Anaconda3" /save "%USERPROFILE%\Desktop\anaconda_acl_backup.txt" /T /C
    icacls "C:\ProgramData\Anaconda3" /inheritancelevel:e /T /C
    
    After that, conda.exe worked normally from a non-elevated Command Prompt, and VS Code could once again switch between Conda interpreters without being run as Administrator.
    
    So for anyone seeing this error—especially with an All Users Anaconda install under C:\ProgramData—it may be worth checking whether the current non-admin user can actually execute Conda:
    
    icacls "C:\ProgramData\Anaconda3\Scripts\conda.exe"
    "C:\ProgramData\Anaconda3\Scripts\conda.exe" --version
    
    In my case this was a Windows filesystem permission / ACL inheritance issue rather than a broken Conda environment. This may be a separate root cause from the original report, since the original reporter noted that running VS Code as Administrator did not help.
  5. lraugustin commented on Aug 25, 2026

    @lraugustin

    Exactly the same issue here, looking forward to a solution

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions