Skip to content

Python environments not detected/found in devcontainer on WSL 2 #24071

@mhabibav

Description

@mhabibav

Type: Bug

Behaviour

I have a Windows machine where VS Code is installed. The machine has WSL 2 (Ubuntu 22.04) where docker is installed.

I can successfully connect to WSL from my VS Code desktop. I have a repo inside WSL with a devcontainer. I can build and use the container normally except for one frustrating thing. Any Python environment created inside the container using Poetry, is not detected by the "Select Interpreter" button. No matter how many times I press the refresh button (in the select interpreter window) or reopen the container; the environments never show up.

Here's a screenshot of the select interpreter window:
image

Here's what's inside ~/.cache/pypoetry/virtualenvs:
image

Here's the output of the Python extension after pressing refresh:
image

Steps to reproduce:

  1. Have WSL 2 with Docker installed inside WSL
  2. Reopen folder in devcontainer
  3. Create a Poetry environment by any means
  4. Open a Python file and press Select Interpreter

Expected behavior: poetry env is automatically detected and is selectable
Current behavior: Environment doesn't show up

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

Extension version: 2024.14.0
VS Code version: Code 1.93.0 (4849ca9bdf9666755eb463db297b69e5385090e3, 2024-09-04T13:02:38.431Z)
OS version: Windows_NT x64 10.0.22631
Modes:
Remote OS version: Linux x64 5.15.146.1-microsoft-standard-WSL2

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


languageServer: "Pylance"

Installed Extensions
Extension Name Extension Id Version
Auto Close Tag formulahendry.auto-close-tag 0.5.15
Auto Rename Tag formulahendry.auto-rename-tag 0.1.10
autoDocstring - Python Docstring Generator njpwerner.autodocstring 0.6.1
Bruno bruno-api-client.bruno 3.1.0
Conventional Commits vivaxy.vscode-conventional-commits 1.26.0
DotENV mikestead.dotenv 1.0.1
ESLint dbaeumer.vscode-eslint 3.0.10
Even Better TOML tamasfe.even-better-toml 0.19.2
Gemini Code Assist + Google Cloud Code googlecloudtools.cloudcode 2.16.7
Git Graph mhutchie.git-graph 1.30.0
Git History donjayamanne.githistory 0.6.20
HashiCorp Terraform hashicorp.terraform 2.32.3
Import Cost wix.vscode-import-cost 3.3.0
IntelliCode API Usage Examples VisualStudioExptTeam.intellicode-api-usage-examples 0.2.8
JavaScript Debugger ms-vscode.js-debug 1.93.0
Jupyter ms-toolsai.jupyter 2024.8.0
Jupyter Cell Tags ms-toolsai.vscode-jupyter-cell-tags 0.1.9
Jupyter Notebook Renderers ms-toolsai.jupyter-renderers 1.0.19
Jupyter Slide Show ms-toolsai.vscode-jupyter-slideshow 0.1.6
Live Server ritwickdey.LiveServer 5.7.9
Markdown Preview Enhanced shd101wyy.markdown-preview-enhanced 0.8.13
Markdown Preview Mermaid Support bierner.markdown-mermaid 1.24.0
npm Intellisense christian-kohler.npm-intellisense 1.4.5
OpenAPI (Swagger) Editor 42Crunch.vscode-openapi 4.28.1
PDF Viewer mathematic.vscode-pdf 0.0.6
Prettier - Code formatter esbenp.prettier-vscode 11.0.0
Pylance ms-python.vscode-pylance 2024.8.2
Python ms-python.python 2024.14.0
Python Debugger ms-python.debugpy 2024.10.0
Python Environment Manager donjayamanne.python-environment-manager 1.2.4
Rainbow CSV mechatroner.rainbow-csv 3.12.0
Ruff charliermarsh.ruff 2024.44.0
Simple React Snippets burkeholland.simple-react-snippets 1.2.8
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.9
XML redhat.vscode-xml 0.27.1
YAML redhat.vscode-yaml 1.15.0

Metadata

Metadata

Assignees

Labels

area-environmentsFeatures relating to handling interpreter environmentsbugIssue identified by VS Code Team member as probable bugtriage-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