Skip to content

Python: Subdirectory .venv not detected by "Python: Select Interpreter" #24971

@muzzlol

Description

@muzzlol

Type: Bug

Behaviour

When creating a virtual environment (.venv) inside a subdirectory of the folder opened in VS Code, the interpreter does not show up in the Python: Select Interpreter dropdown. However, when the .venv is created in the root directory (where VS Code was opened), it is correctly detected.


Steps to reproduce:

  1. Run the following commands in terminal:

    mkdir -p dir/subdir
    cd dir
    code .
  2. In the VS Code workspace root (dir), run:

    python3 -m venv venv
  3. Open Command Palette (Cmd+Shift+P) → Python: Select Interpreter
    ✅ The ./venv interpreter is listed.

  4. Now instead of root, do this:

    cd subdir
    python3 -m venv venv
  5. Go back to the Command Palette → Python: Select Interpreter
    ❌ The new subdir/venv interpreter is not listed, even though it exists and is valid.

Expected: All .venv folders within the workspace (even in subdirectories) should be detected or at least be selectable from the interface.


Diagnostic data

launch.json configuration
Output for Python in the Output panel
(no relevant logs - interpreter just not detected)
Output for Python Debugger in the Output panel
(no relevant logs - issue happens before debugging)

Extension version: 2025.4.0
VS Code version: Code 1.98.2 (Universal) (ddc367ed5c8936efe395cffeec279b04ffd7db78, 2025-03-12T13:32:45.399Z)
OS version: Darwin arm64 24.3.0
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda):
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Unknown
  • Value of the python.languageServer setting: Default
User Settings


languageServer: "Pylance"

Installed Extensions
Extension Name Extension Id Version
ayu tea 1.0.5
code-runner for 0.12.2
codesnap adp 1.3.4
copilot Git 1.284.0
copilot-chat Git 0.25.1
debugpy ms- 2025.4.1
es7-react-js-snippets dsz 4.4.3
figma-vscode-extension fig 0.4.0
go gol 0.46.1
js-debug ms- 1.97.1
js-debug-companion ms- 1.1.3
jupyter ms- 2025.2.0
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.1.0
languague-renpy cob 2.0.0
live-server ms- 0.4.15
LiveServer rit 5.7.9
makefile-tools ms- 0.12.17
material-icon-theme PKi 5.20.0
prettier-vscode esb 11.0.0
python ms- 2025.2.0
rainbow-csv mec 3.18.0
remote-containers ms- 0.401.0
TabOut alb 0.2.2
vscode-docker ms- 1.29.4
vscode-js-profile-table ms- 1.0.10
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
vscode-proto3 zxh 0.5.5
vscode-pull-request-github Git 0.106.0
vscode-pylance ms- 2025.3.2
vscode-tailwindcss bra 0.14.9
System Info
Item Value
CPUs Apple M2 (8 x 2400)
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
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 2, 3, 4
Memory (System) 8.00GB (0.14GB free)
Process Argv . --crash-reporter-id 548eaa6f-0eef-4f3f-a3f7-ca08a4f49cc4
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupytercf:31046870
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc2:31192216
iacca1:31171482
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
9064b325:31222308
copilot_t_ci:31222730
f5992895:31259995
jda6j935:31233686
pythoneinst12:31262605
bgtreat:31262795
fh1c7952:31258891
6h6a5794:31261449
31787653:31262186
0339e702:31259951

Metadata

Metadata

Assignees

Labels

triage-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