-
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
Terminal doesn't activate selected conda environment #22068
Comments
I found a solution, although I don't know what's the reason for this issue. I added "conda activate my-env-name" as The full related setting:
} |
Please provide the debug logs after you start seeing the issue:
Output for
|
Thanks a lot for the reply. I deleted "conda activate my-env" and again terminal did not activate selected conda environment. Sorry for the long log. |
I switch to pre-release version and reload window, but it doesn't work. I am not quite sure what kind of User setting you need. |
Hi @suipz This is a very old problem that I have been facing at least on macOS since I started using virtual environments. One working fix to this problem that I found was to change the "code-runner.executerMap" in settings.json under the key "python" to "$pythonPath $fullFileName". I found setting "python.terminal.activateEnvironment": false; to be efficient in programs that take user input. Because it keeps on running till the environment gets activated (program takes this as the user input, thus causing a bug). Although it does not solve the problem but all the code will run with the environment as selected in the interpreter path. The reason for this was, terminal would activate my environment after a delay, due to which the program runs without the environment being activated (it gets activated after that). |
@suipz Can you also remove the "args" parameter activating conda base env from User settings? Alternatively please switch to default powershell profile using |
Thanks for your reply. |
I tried again.
|
Appreciate you giving it a try. If I understand correctly, once args is removed:
I'm not very clear on this bit. I would ideally expect all terminals to behave the same once they're relaunched. Can you dispose all terminals by clicking the 🗑️ icon and try it? Would really help if I could get some screenshots on how you're inferring whether the correct env was activated. |
BTW, it's showed that py37 activated in the 2nd screenshot, but it's not in fact. |
Thanks for the deets, we're very close. I'm able to reproduce the issue but under very specific conditions.
Note environments take some time to activate (we don't a good job surfacing this, something we can improve), I think if you wait long enough before running the Python file (or opening a new terminal), you should not see the Also, this should only happen the first time an env is selected (and reasonable time is given for it to activate). Once you dispose all terminals with |
If that still does not work for you, please provide the logs again #22068 (comment) after doing the steps needed to reproduce the issue. |
I tested again. Yes, just as you said, it's no problem after waited for 15min. |
No worries! I'll just make the quick fix to show a progress indicator to help you with how long it takes to re-activate the environment, after which we can close this. Thanks for the help. |
Once you reload the window after installing it, you should be able to see the indicator. |
Thanks a lot for your help. And then I switched back to release version and tried again. That's all. Thanks again. |
Type: Bug
Behaviour
Expected vs. Actual
I am using Windows 10 and Anaconda for virtual environments.
recently, I change from spyder to vs code. it works fine.
But yesterday, when I started a new terminal or run a python file, new terminal did not activate the selected virtual env (Conda).
It DO work before. But didn't after I installed the follows on Friday.
currently, I tried to uninstall New Python (3.9.9) and reinstall vs code (after delete everything, it's a clean new install), but still doesn't work.
I know this is the same issue as #20885, but I tried all solutions mentioned in # 20885 and failed.
XXX
Steps to reproduce:
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.16.0
VS Code version: Code 1.82.2 (abd2f3db4bdb28f9e95536dfa84d8479f1eb312d, 2023-09-14T05:55:25.390Z)
OS version: Windows_NT x64 10.0.19045
Modes:
System Info
canvas_oop_rasterization: enabled_on
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: