Skip to content
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

Virtual environments not found #24788

Open
mgeorge-is opened this issue Feb 6, 2025 · 11 comments
Open

Virtual environments not found #24788

mgeorge-is opened this issue Feb 6, 2025 · 11 comments
Assignees
Labels
area-environments Features relating to handling interpreter environments info-needed Issue requires more information from poster

Comments

@mgeorge-is
Copy link

mgeorge-is commented Feb 6, 2025

Type: Bug

Behaviour

Hatch virtual environments are not displayed when using the command palette Python: Select Interpreter (or similarly when using the Jupyter extensions Select Kernel option).

Steps to reproduce:

  1. Update the VS Code python extension to 2024.18.0 or later.
  2. Using hatch env create, create multiple virtual environments. By default they are placed in the .hatch directory of the workspace root.
  3. Open command palette Python: Select Interpreter (or Jupyter extension Select Kernel) and local environments will not be listed.
  4. Revert VS Code python extension to 2024.16.1 and restart and the environments are displayed as expected.

Diagnostic data

The issue is reproducible in all versions 2024.18.0 and higher. Possibly related to this commit which fixed an unrelated duplication issue: #24321

2024.16.1
Image

2024.18.0
Image

Extension version: 2024.18.0
VS Code version: Code 1.96.4 (Universal) (cd4ee3b1c348a13bafd8f9ad8060705f6d4b9cba, 2025-01-16T00:16:19.038Z)
OS version: Darwin arm64 24.3.0
Modes:

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


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true

Installed Extensions
Extension Name Extension Id Version
autoDocstring - Python Docstring Generator njpwerner.autodocstring 0.6.1
C/C++ ms-vscode.cpptools 1.23.5
C/C++ Extension Pack ms-vscode.cpptools-extension-pack 1.3.0
C/C++ Themes ms-vscode.cpptools-themes 2.0.0
CMake twxs.cmake 0.0.17
CMake Tools ms-vscode.cmake-tools 1.19.52
Code Spell Checker streetsidesoftware.code-spell-checker 4.0.34
Dev Containers ms-vscode-remote.remote-containers 0.394.0
Docker ms-azuretools.vscode-docker 1.29.4
Even Better TOML tamasfe.even-better-toml 0.21.2
GitHub Actions github.vscode-github-actions 0.27.1
GitHub Pull Requests GitHub.vscode-pull-request-github 0.102.0
GitHub Repositories GitHub.remotehub 0.64.0
JavaScript Debugger ms-vscode.js-debug 1.96.0
JavaScript Debugger Companion Extension ms-vscode.js-debug-companion 1.1.3
Jupyter ms-toolsai.jupyter 2024.11.0
Jupyter Cell Tags ms-toolsai.vscode-jupyter-cell-tags 0.1.9
Jupyter Keymap ms-toolsai.jupyter-keymap 1.1.2
Jupyter Notebook Renderers ms-toolsai.jupyter-renderers 1.1.0
Jupyter Slide Show ms-toolsai.vscode-jupyter-slideshow 0.1.6
Makefile Tools ms-vscode.makefile-tools 0.11.13
Mypy Type Checker ms-python.mypy-type-checker 2024.0.0
Pylance ms-python.vscode-pylance 2025.2.1
Pylint ms-python.pylint 2024.0.0
Python ms-python.python 2024.18.0
Python Debugger ms-python.debugpy 2024.14.0
Remote Repositories ms-vscode.remote-repositories 0.42.0
Rewrap stkb.rewrap 1.16.3
Ruff charliermarsh.ruff 2025.4.0
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.10
VS Code Counter uctakeoff.vscode-counter 3.6.2
YAML redhat.vscode-yaml 1.15.0
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 6, 2025
@anthonykim1
Copy link

@mgeorge-is Is your locator native or js?

Image

@anthonykim1 anthonykim1 reopened this Feb 6, 2025
@anthonykim1 anthonykim1 added area-environments Features relating to handling interpreter environments and removed triage-needed Needs assignment to the proper sub-team labels Feb 6, 2025
@github-actions github-actions bot added info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team labels Feb 6, 2025
@anthonykim1 anthonykim1 removed the triage-needed Needs assignment to the proper sub-team label Feb 6, 2025
@mgeorge-is
Copy link
Author

mgeorge-is commented Feb 6, 2025

@mgeorge-is Is your locator native or js?

Image

@anthonykim1: js (edit: this setting is for version 2024.16.1 which I have pinned so I can continue working. It is native if I update to 2024.18.0 (not working)).

Image

@lvm-1896
Copy link

lvm-1896 commented Feb 7, 2025

I'm also experiencing problems with the python.locator setting. When set to native PET.EXE ist blocked from execution by AppLocker. There is an entry in the log files, but no indication in the GIU. I my case, no python runtimes could be found. Not even the runtime installed by VS Code itself. VS Code is a system installation, but PET.EXE is in my user profile where the python extension lives.

@karthiknadig
Copy link
Member

@mgeorge-is Does it work if you select it by navigating to it?

@lvm-1896 You may need to add either Microsoft Publisher or the specific pet file as an exception to AppLocker: https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/applocker/configure-exceptions-for-an-applocker-rule

@jdegenstein
Copy link

Ran into this issue too on a brand new install of VSCode and vscode-python extension. What helped was switching locator off of native to js (and I restarted VSCode for good measure too).

@mgeorge-is
Copy link
Author

@mgeorge-is Does it work if you select it by navigating to it?

@lvm-1896 You may need to add either Microsoft Publisher or the specific pet file as an exception to AppLocker: https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/applocker/configure-exceptions-for-an-applocker-rule

@karthiknadig: yes, I can select an environment that is not detected via Command Palette -> Select Interpreter -> Enter interpreter path. But this does not work for Jupyter notebooks. Select Kernel -> Select Another Kernel -> Python Environments and then there is no enter interpreter path option. So there is a workaround in the first case but not the second.

@karthiknadig
Copy link
Member

Thanks, I will investigate. For now please use the workaround.

@lvm-1896
Copy link

@lvm-1896 You may need to add either Microsoft Publisher or the specific pet file as an exception to AppLocker: https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/applocker/configure-exceptions-for-an-applocker-rule

I switched back to JS and the user can work again now. I'll try to get the AppLocker exception deployed for the userbase in my enterprise (~ 600 installations). AFAICS PET.EXE ist the first executable installed outside the installation directory (VS Code system installation), so the requirement for further exceptions was a bit suprising for me and it took quite a while to find the reason for failing python support. Maybe ist is possible to bring up a user visible message in case the locator fails? Or even better provide an automatic fallback with a warning? Failure to detect python on all workstations would have been a nightmare for me ...

@carlosles
Copy link

I'm on VS Code version 1.97.2 on arm64 macOS and was frustrated having experienced this issue. Fortunately the switch to the old js locator worked.

@lvm-1896
Copy link

@mgeorge-is : I tried to follow your suggestion to setup an AppLocker exception for pet.exe. Because pet.exe is missing a product info, I'm having trouble to convince my admistrators to add an exception for all Microsoft-signed executables.

Image

@mgeorge-is
Copy link
Author

@mgeorge-is : I tried to follow your suggestion to setup an AppLocker exception for pet.exe. Because pet.exe is missing a product info, I'm having trouble to convince my admistrators to add an exception for all Microsoft-signed executables.

Image

@lvm-1896, I opened the original issue (environment locators not working). I am not a VS Code developer. I suggest you open a new issue for your problem to prevent confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-environments Features relating to handling interpreter environments info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

6 participants