-
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
Correct Python environment in terminal no longer loads #21943
Comments
In addition, now some Python scripts can no longer resolve packages that are certainly installed in the environment selected in the bottom right. E.g., now This is making development frustrating and I would really appreciate a fix soon. Thank you! |
I will let @karrtikr investigate further, but this setting should be an array:
|
Thanks @karthiknadig, pretty sure I had that but messed it up when I pasted it into the Issue. To be clear, my file {
"python.experiments.optInto": ["pythonTerminalEnvVarActivation"]
} and this still does not work even when restarting VS Code. Thanks, looking forward to getting this resolved @karrtikr et. al. |
Hi @andrew-weisman 👋 Can you please provide the Python debug logs? Steps:
|
Lastly, try running the following command in terminal and see if it matches if the selected environment:
|
Thanks @karrtikr: Python debug logs:
Environment contributions (there is no Python section!):
Python version command:
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Sure, that stuck this time:
|
Can you try running
in bash terminal and send me the output? |
Sure @karrtikr, here it is in a new WSL bash terminal (I assume you forgot the "." to source the activate script):
Here it is in a new VS Code bash terminal:
|
Thanks, are you using Remote WSL? Note Python logs from those can be different. |
Everything looks good when looking at this info, ideally the env variables you see in the output: Meanwhile, you can opt out of the experiment using
which should revert back to original behavior. |
Yes I am "remotely" connecting to WSL. But the problem occurs whether or not I have |
To be clear, I'm suggesting you to set "optOutFrom", not "optInto" as you mentioned here #21943 (comment). |
Ah my bad, thanks @karrtikr. That works well enough. It's not reverted to the original behavior because now the "base" conda environment is also active instead of just the selected environment (in this case, "testing_streamlit"). Previously, only testing_streamlit was activated. But that doesn't seem to cause any issues for me yet, and, while not ideal, I can always run "conda deactivate" to get rid of "(base)". Thanks for your help! |
To get rid of
This behavior actually comes from conda itself, not VS Code. |
Btw, can you do me a favor and try installing VS Code Insiders: #11039 (comment). I think the issue is that you're on VS Code Stable, which does not have all the fixes yet, ideally you should not have been part of the experiment. |
Thanks, yes I can run |
Also, the problem of libraries in my scripts not being found anymore still occurs, it's pretty frustrating. Any advice aside from using VS Code Insiders? E.g., even though my environment is "testing_streamlit", my "import streamlit" statement is still flagged by Pylance. This didn't happen before I first got: Thank you. |
Do you still get this prompt, even after opting out of experiment? If you do can please provide the logs again |
Yep just upgraded and I don't get the prompt anymore even after removing the opt-out from my JSON file (so this file is empty). Problems still occurring since these updates:
Thank you. |
Is the correct environment activated in terminal? Try the sys.executable command I mentioned earlier to find out. |
Gotcha, seeing as the original issue seems fixed let's tackle it in a new thread so everyone has a fresh context. Can you use |
Thanks @karrtikr. Looks like this was fixed with an update to Pylance pre-release just now, v2023.9.12. E.g., no longer complaining that it can't find the streamlit library. The (base) conda environment still no longer gets deactivated but I'm fine with that. Thanks for your help! |
Type: Bug
Behaviour
Expected vs. Actual
Broke a couple days ago (around 9/5/23?). Previously, when a Python environment was selected in the bottom right (I'm using WSL2), when I opened a terminal, the corresponding venv Python environment would automatically load.
Now, I have to manually source the venv
activate
script.I have tried putting
"python.experiments.optInto": "pythonTerminalEnvVarActivation"
into my remote WSL settings.json, but this does not help. Even upon restarting VS Code.I have looked through both here and here but I have not found anything helpful. Perhaps I missed something.
Thanks in advance.
Steps to reproduce:
python
in the terminal and importing a library I know exists (using e.g.import streamlit
) throws an importerror.Diagnostic data
python.languageServer
setting: DefaultOutput for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)User Settings
Extension version: 2023.15.12301911
VS Code version: Code 1.81.1 (6c3e3dba23e8fadc360aed75ce363ba185c49794, 2023-08-09T22:22:42.175Z)
OS version: Windows_NT x64 10.0.22621
Modes:
Remote OS version: Linux x64 5.10.16.3-microsoft-standard-WSL2
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
A/B Experiments
The text was updated successfully, but these errors were encountered: