Skip to content

Python Extension Fails to Auto-Detect Venv on SMB Network Drive #25526

Description

@Alpeflug

We have written the needed data into your clipboard because it was
Type: Bug

Hi all

Issue Title:
Python Extension Fails to Auto-Detect Venv on SMB Network Drive (Z:) with ENOENT Scandir Error in AppData

Environment

  • VS Code Version: 1.95.0 (or latest as of October 13, 2025)
  • Python Extension Version: 2025.16.0
  • Python Version: 3.13.4 (global and in venv)
  • OS and Version: Windows 11 (or your version), 64-bit
  • Relevant Extensions: ms-python.python (2025.16.0), ms-python.debugpy (2025.14.0), ms-python.pylance (2025.8.3)
  • Other Info: Project on SMB-mapped network drive (Z:, not local C:). No Poetry/Conda/Pixi used – plain python -m venv .venv.

Steps to Reproduce

  1. Create a new project folder on a network drive, e.g., Z:\0400 Dokumentation\0001 IT Dokumentation\0001 Skripte\PY_Test_with_GROK.
  2. In PowerShell (project root): python -m venv .venv (creates venv successfully; Test-Path .\.venv\Scripts\python.exe returns True).
  3. Activate venv: .\.venv\Scripts\Activate.ps1 > pip install requests > Deactivate. (Venv works: python -c "import requests; print(requests.__version__)" outputs 2.32.5.)
  4. Create .vscode/settings.json:
    {
        "python.defaultInterpreterPath": "./.venv/Scripts/python.exe",
        "python.terminal.activateEnvironment": true
    }
  5. Open VS Code in the folder: code . (from PowerShell in root).
  6. Status bar shows "Select Interpreter" triangle. Command Palette > "Python: Select Interpreter" > Enter absolute path Z:\0400 Dokumentation\0001 IT Dokumentation\0001 Skripte\PY_Test_with_GROK\.venv\Scripts\python.exe – selects successfully, status bar updates to correct path.
  7. Create src/main.py with sample code (e.g., import requests; response = requests.get('https://api.github.com'); print(response.status_code)).
  8. Press F5 on main.py: Debugger starts, but logs show warnings/errors.

Expected Behavior

  • Venv auto-detected from relative path in settings.json.
  • No scan errors; status bar updates automatically.
  • F5 debugs using venv interpreter without manual selection or launch.json tweaks.
  • Terminal auto-activates venv with (.venv) prefix.

Actual Behavior

  • "Select Interpreter" triangle persists until manual absolute path selection.
  • Logs (Output > Python) show repeated warnings:
    [warning] Identifier for virt-virtualenv failed to identify .venv\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir 'C:\Users\tuzi\AppData\Local\Programs\Microsoft VS Code\.venv\Scripts'] {
      errno: -4058,
      code: 'ENOENT',
      syscall: 'scandir',
      path: 'C:\\Users\\tuzi\\AppData\\Local\\Programs\\Microsoft VS Code\\.venv\\Scripts'
    }
    
    (Extension scans wrong AppData path instead of Z:\ project.)
  • Additional warning: Dir "z:\0400 Dokumentation\0001 IT Dokumentation\0001 Skripte\PY_Test_with_GROK\.pixi\envs" is not watchable (directory does not exist) – scans for non-existent Pixi envs.
  • F5 prompts "Select Debugger" loop: "Python Debugger" > "Python File" > "create a launch.json file" > Loops back to config menu.
  • Manual launch.json creation in .vscode with absolute "python" path fixes F5, but relative paths fail.
  • Terminal activates venv manually, but auto-activation inconsistent.

Logs (from Output > Python, after Reload Window)

2025-10-13 01:56:43.567 [warning] Identifier for virt-virtualenv failed to identify .venv\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir 'C:\Users\tuzi\AppData\Local\Programs\Microsoft VS Code\.venv\Scripts'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'C:\\Users\\tuzi\\AppData\\Local\\Programs\\Microsoft VS Code\\.venv\\Scripts'
}
2025-10-13 01:56:43.908 [info] Finished searching for windows registry interpreters: 589 milliseconds
2025-10-13 01:56:43.910 [info] Environments refresh paths discovered (event): 591 milliseconds
2025-10-13 01:56:43.910 [info] Environments refresh paths discovered: 591 milliseconds
2025-10-13 01:56:43.958 [info] Environments refresh finished (event): 639 milliseconds
2025-10-13 01:56:43.965 [info] Environment refresh took 647 milliseconds
2025-10-13 01:56:52.885 [info] Active interpreter [z:\0400 Dokumentation\0001 IT Dokumentation\0001 Skripte\PY_Test_with_GROK]:  Z:\0400 Dokumentation\0001 IT Dokumentation\0001 Skripte\PY_Test_with_GROK\.venv\Scripts\python.exe
2025-10-13 01:56:52.909 [info] Python interpreter path: .\.venv\Scripts\python.exe
2025-10-13 01:56:52.910 [info] Discover tests for workspace name: PY_Test_with_GROK - uri: z:\0400 Dokumentation\0001 IT D

2025-10-13 02:14:57.902 [info] Telemetry level is off
2025-10-13 02:14:57.902 [info] Experiments are disabled, only manually opted experiments are active.
2025-10-13 02:14:57.902 [warning] Dir "z:\0400 Dokumentation\0001 IT Dokumentation\0001 Skripte\PY_Test_with_GROK\.pixi\envs" is not watchable (directory does not exist)
2025-10-13 02:14:58.110 [info] Python interpreter path: .\.venv\Scripts\python.exe
2025-10-13 02:14:58.141 [info] > pyenv which python
2025-10-13 02:14:58.141 [info] cwd: z:\0400 Dokumentation\0001 IT Dokumentation\0001 Skripte\PY_Test_with_GROK
2025-10-13 02:15:02.724 [info] Starting Pylance language server.

Additional Notes

Greetings

Don Jayamanne (@DonJayamanne)
Brett Cannon (@brettcannon)

VS Code version: Code 1.105.0 (03c265b1adee71ac88f833e065f7bb956b60550a, 2025-10-08T14:09:35.891Z)
OS version: Windows_NT x64 10.0.26100
Modes:

System Info
Item Value
CPUs AMD Ryzen 7 5700U with Radeon Graphics (16 x 1797)
GPU Status 2d_canvas: enabled
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
trees_in_viz: 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.34GB (18.74GB free)
Process Argv Z:\ --goto Z:\status.md
Screen Reader no
VM 0%
Extensions (17)
Extension Author (truncated) Version
emojisense bie 0.10.0
markdown-preview-github-styles bie 2.2.0
gitlens eam 17.6.1
vscode-containers ms- 2.2.0
black-formatter ms- 2025.2.0
debugpy ms- 2025.14.0
isort ms- 2025.0.0
pylint ms- 2025.2.0
python ms- 2025.16.0
vscode-pylance ms- 2025.8.3
powershell ms- 2025.4.0
vsliveshare ms- 1.0.5959
autodocstring njp 0.6.1
material-icon-theme PKi 5.27.0
LiveServer rit 5.7.9
markdowntable Tak 0.13.0
markdown-all-in-one yzh 3.6.3
too large to send. Please paste.

Activity

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

Metadata

Metadata

Labels

area-environmentsFeatures relating to handling interpreter environmentsinfo-neededIssue requires more information from poster

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions