-
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 interpreter settings ignored if VS Code is launched from an activated environment #23833
Comments
@julianstirling If you open VS Code from an activated environment, the environment variables that we see are from that activated environment. Now when you change the selected environment, we try to change the environment. But this behavior can be non deterministic, how we select and use something strongly relies on how the environment variables are set. That said, the extension should just use the selected environment. We are working on re-doing how this mechanism works. I think the re-write of this should be able deal with scenarios like this better. But I am not entirely sure that we can clear out all the possible environment variables for the various combination of activated environments to selected environment conversion. |
This comment was marked as resolved.
This comment was marked as resolved.
Yes, automatic activation for conda environments doesn't seem to be working for me either anymore. I've tried a few of the last versions of the extension, and I cannot get it to work with any of them, so I wonder if it was a vscode update. EDIT: I don't know what's going on, but it just started working again for me |
Update: I switched Python extension to a month ago (2024.10.0) and things are working again :) |
Had the same problem after some extension update. Looks like vscode-python 2024.12.3 is breaking Python interpreters on MacOS. I solved by installing the latest dev version (v2024.13.2024081501). |
Same here. I am using remote SSH. The newer extension is not showing VENVs. 2024.10.0 is working fine. |
Would that also solve #23571? |
The latest python extension keep choosing Additional problem is all the other extensions (pylint, isort, black) also keep using |
Agreed that external tools are the most important. It is a little annoying that the wrong virtual env is set in the terminal, but also easy to fix. Having the wrong environment for linting is much harder to identify and fix. |
This also comes up with Unittest Discovery. Even after setting an interpreter, the interpreter that was active while launching Vscode is used. |
Type: Bug
Behaviour
When I open VSCode the python interpreter selected is inconsistent. It certainly to depends on:
I am not certain if other things also affect it, for a while I thought it was the history of what I did last time I had vscode open (as persistent terminals also caused me issues, but this I cannot reproduce). I have had continued issues with getting environments to persist in workspaces since the interpreter settings were changed from the
settings.json
a couple of years back 2022.Every time I open a project I have to use "Python: Select Interpreter" again. I assume part of the problem is that the way my system is configured, I almost always have a python virtual environment activated. As I always launch vscode from the terminal, it seems to try to use the interpreter from the environment I launched it from, rather than the interpreter I have set.
I understand that this may be a feature not a bug, some people may want the virtual environment from the launching terminal to override workspace settings. The ideal solution would be a global settings in settings.json to never try to guess my python interpreter from virtual environments. Or anything else except how I set it for the workspace (or my default interpreter setting).
Steps to reproduce:
.bashrc
)code .
Diagnostic data
Extension version: 2024.10.0
VS Code version: Code 1.90.2 (5437499feb04f7a586f677b155b039bc2b3669eb, 2024-06-18T22:33:48.698Z)
OS version: Linux x64 5.4.0-182-generic
Modes:
python.languageServer
setting: NoneUser Settings
Installed Extensions
System Info
canvas_oop_rasterization: disabled_off
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: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
The text was updated successfully, but these errors were encountered: