-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python environments not detected/found in devcontainer on WSL 2 #24071
Comments
Here's the output of the Python Extension: Python extension output
I noticed it had 2 errors and both apparently are due to the extension mixing up Windows and Unix paths? |
The 2 errors turned out to be because I had set |
@mhabibav We don't know the paths where In both cases you can set it and then do refresh by running |
Hello @karthiknadig thanks for your reply!
I haven't changed any of Poetry's configurations so I guess all environments are created in
Still not showing up, here's a screenshot from the logs.
|
Can you share your settings.json? @DonJayamanne is the |
I do not hardcode that path in pet, |
Would it be possible to share this dev container (i.e. just the docker file or the base image used) |
User settings.json{
////////////////////////////////////////////////////////////////////////////
// Window
////////////////////////////////////////////////////////////////////////////
"window.restoreWindows": "none",
"window.zoomLevel": 0,
////////////////////////////////////////////////////////////////////////////
// Workbench
////////////////////////////////////////////////////////////////////////////
"workbench.editor.restoreViewState": false,
"workbench.tree.enableStickyScroll": true,
"workbench.editor.showTabs": "multiple",
"workbench.colorTheme": "Noctis Obscuro",
"workbench.sideBar.location": "right",
"workbench.iconTheme": "vscode-icons",
"workbench.editor.alwaysShowEditorActions": true,
////////////////////////////////////////////////////////////////////////////
// Explorer
////////////////////////////////////////////////////////////////////////////
"explorer.compactFolders": false,
////////////////////////////////////////////////////////////////////////////
// Editor
////////////////////////////////////////////////////////////////////////////
"editor.fontLigatures": true,
"editor.fontFamily": "'Cascadia Code', 'Fira Code', 'Source Code Pro', Consolas, 'Courier New', monospace",
"editor.fontSize": 14,
"editor.inlineSuggest.enabled": true,
"editor.stickyScroll.enabled": true,
"editor.rulers": [
80,
100,
120,
],
////////////////////////////////////////////////////////////////////////////
// Terminal
////////////////////////////////////////////////////////////////////////////
"terminal.integrated.scrollback": 10000,
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.fontFamily": "'Cascadia Code NF', 'Fira Code', 'Source Code Pro', Consolas, 'Courier New', monospace",
////////////////////////////////////////////////////////////////////////////
// Language
////////////////////////////////////////////////////////////////////////////
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
// "[cpp]": {
// "editor.defaultFormatter": "ms-vscode.cpptools"
// },
////////////////////////////////////////////////////////////////////////////
// Extension
////////////////////////////////////////////////////////////////////////////
// Python
// "python.languageServer": "Pylance",
"python.locator": "native",
"python.analysis.fixAll": [
"source.unusedImports"
],
"python.venvFolders": [
"~/.cache/pypoetry/virtualenvs"
],
"python.analysis.inlayHints.functionReturnTypes": true,
"debugpy.debugJustMyCode": false,
"jupyter.debugJustMyCode": false,
// Red Hat
"redhat.telemetry.enabled": false,
// icons
"vsicons.dontShowNewVersionMessage": true,
// notebook
"notebook.lineNumbers": "on",
////////////////////////////////////////////////////////////////////////////
// Other
////////////////////////////////////////////////////////////////////////////
"telemetry.telemetryLevel": "off",
"git.openRepositoryInParentFolders": "never",
} devcontainer settings.json{
"terraform.languageServer.enable": true,
"terraform.languageServer.args": [
"serve"
],
"azureTerraform.terminal": "integrated",
"terminal.integrated.defaultProfile.linux": "zsh",
"extensions.autoUpdate": true,
"dev.containers.workspaceMountConsistency": "consistent",
"telemetry.telemetryLevel": "off",
"redhat.telemetry.enabled": false,
"cloudcode.enableTelemetry": false,
"files.associations": {
".env*": "dotenv"
},
"conventionalCommits.autoCommit": false,
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[yaml]": {
"editor.autoIndent": "full"
},
}
devcontainer.json// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "devcontainer name",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:noble",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers-contrib/features/copier:7": {},
"ghcr.io/devcontainers-contrib/features/poetry:2": {},
"ghcr.io/devcontainers-contrib/features/ruff:1": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/dhoeric/features/act:1": {},
"ghcr.io/dhoeric/features/google-cloud-cli:1": {
"installGkeGcloudAuthPlugin": true
},
"ghcr.io/devcontainers-contrib/features/jfrog-cli:1": {},
"ghcr.io/devcontainers/features/terraform:1": {
"version": "1.5.7"
}
},
// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
// AI Stuff
"googlecloudtools.cloudcode",
"VisualStudioExptTeam.intellicode-api-usage-examples",
// Git Stuff
"mhutchie.git-graph",
"donjayamanne.githistory",
"vivaxy.vscode-conventional-commits",
// Python Stuff
"ms-python.python",
"ms-toolsai.jupyter",
"charliermarsh.ruff",
"njpwerner.autodocstring",
"donjayamanne.python-environment-manager",
// Generic Stuff
"ms-azuretools.vscode-docker",
"hashicorp.terraform",
"redhat.vscode-xml",
"redhat.vscode-yaml",
"tamasfe.even-better-toml",
"mechatroner.rainbow-csv",
"mathematic.vscode-pdf",
"shd101wyy.markdown-preview-enhanced",
"bierner.markdown-mermaid",
"mikestead.dotenv",
"bruno-api-client.bruno",
"42Crunch.vscode-openapi",
// Web Stuff
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"christian-kohler.npm-intellisense",
"ritwickdey.LiveServer",
"wix.vscode-import-cost",
"formulahendry.auto-close-tag",
"formulahendry.auto-rename-tag",
"burkeholland.simple-react-snippets",
// Prevented Stuff
"-ms-python.autopep8",
"-ms-azuretools.vscode-azureterraform"
],
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh",
"extensions.autoUpdate": true,
"dev.containers.workspaceMountConsistency": "consistent",
"telemetry.telemetryLevel": "off",
"redhat.telemetry.enabled": false,
"cloudcode.enableTelemetry": false,
"files.associations": {
".env*": "dotenv"
},
"conventionalCommits.autoCommit": false,
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[yaml]": {
"editor.autoIndent": "full"
}
}
}
},
// Sepcify minimum resource needs
"hostRequirements": {
"cpus": 4,
"memory": "4gb",
"storage": "32gb",
"gpu": "optional"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'onCreateCommand', 'postCreateCommand' to run commands after the container is created.
"onCreateCommand": {
"default-apt-packages": "sudo apt update && sudo apt upgrade -y && sudo apt install -y build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev git git-lfs"
},
"postCreateCommand": {
"git": "git config --global http.sslverify false && git lfs install",
// "pyenv": "curl https://pyenv.run | bash && echo 'export PYENV_ROOT=\"$HOME/.pyenv\"' | tee -a ~/.zshrc ~/.zprofile ~/.bashrc ~/.profile && echo 'command -v pyenv >/dev/null || export PATH=\"$PYENV_ROOT/bin:$PATH\"' | tee -a ~/.bashrc ~/.profile && echo '[[ -d $PYENV_ROOT/bin ]] && export PATH=\"$PYENV_ROOT/bin:$PATH\"' | tee -a ~/.zshrc ~/.zprofile && echo 'eval \"$(pyenv init -)\"' | tee -a ~/.zshrc ~/.zprofile ~/.bashrc ~/.profile && . ~/.profile && pyenv update && pyenv install 3.12 && pyenv rehash && pyenv global 3.12",
"poetry": "poetry config virtualenvs.prefer-active-python true"
}
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
} |
Unfortunately I'm unable to load the container at my end,
Will try this on a windows machine, @karthiknadig are you able to test this at your end.. |
@mhabibav Sorry for the radio silence, was on leave for a few weeks. Please can you
Copy all of the output and paste it here. |
@DonJayamanne No problem. Thanks for your time anyway, I really appreciate it :D output of pet find -v
I can see here that the home directory is not searched at all. |
@mhabibav
|
Output of poetry config --list
|
@mhabibav |
Please can you install the latest pre-release version of pylance as well @karthiknadig Any idea whats going on here? |
I am on the latest compatible pre-release versions of Python, Pylance, Python Debugger extensions. The first time I hit install it installs the latest version, then shows this warning, and finally downgrades to Tried in a fresh container, got the same error. |
Is it possible for you to install VS Code Insiders, and try again. Once again thank you for your patience. |
I'm not sure if I can install the insiders version, so I will be waiting for a couple days and try again then give you an update. Thanks a lot. |
Hello @DonJayamanne I just updated VS Code and tried the pre-release version of the Python extension and it works perfectly! Thanks a lot, you're a lifesaver ❤️ Please let me know when this will be included in the official release. |
@mhabibav it should be included in the 2024.16.0 release. |
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:
Here's what's inside
~/.cache/pypoetry/virtualenvs
:Here's the output of the Python extension after pressing refresh:
Steps to reproduce:
Expected behavior: poetry env is automatically detected and is selectable
Current behavior: Environment doesn't show up
Diagnostic data
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)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.languageServer
setting: PylanceUser Settings
Installed Extensions
The text was updated successfully, but these errors were encountered: