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

Terminal Activates the Wrong Conda Environment #24680

Closed
yonaroz opened this issue Jan 6, 2025 · 1 comment
Closed

Terminal Activates the Wrong Conda Environment #24680

yonaroz opened this issue Jan 6, 2025 · 1 comment
Assignees
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@yonaroz
Copy link

yonaroz commented Jan 6, 2025

Type: Bug

Behaviour

  • Selecting a conda env as the default interpreter of a python project enables it, but after a day or two, the selected environment turns to "base".
  • Hovering the shell tab shows the correct path of the env, but for some reason the prompt shows "base" is activated.
  • which python also returns the unexpected path.
  • Also in the drop down menu selecting the python env, the name of the env with the currect path disaplys "base".
  • Clicking "Show Environment Contribution" opens the editor and displays wrong paths and names for the conda env.
  • Currently the only resolution for me is to recreate the env untill next time it happens.

Steps to reproduce:

(Working on remote ssh)

  1. Create a conda env using conda create -n hello-world python=3.10.
  2. Select it in a pyton project.
  3. Wait a while (probably something unwanted happens).
  4. Open a new shell and all of the above explained unexpected is now shown.
  5. A notification pops up every time I open a new shell with this message: "Selected conda environment was successfully activated, even though "(base)" indicator may not be present in the terminal prompt. Learn more."

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2025-01-06 11:04:24.496 [info] Experiment 'pythonRecommendTensorboardExt' is active
2025-01-06 11:04:24.496 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2025-01-06 11:04:24.496 [info] Experiment 'pythonTestAdapter' is active
2025-01-06 11:04:24.496 [info] Native locator: Refresh started
2025-01-06 11:04:24.496 [info] Native locator: Refresh started
2025-01-06 11:04:25.678 [info] > pyenv which python
2025-01-06 11:04:25.679 [info] cwd: .
2025-01-06 11:04:26.340 [info] > conda info --json
2025-01-06 11:04:26.902 [info] Conda environment manager found at: /usr/local/conda/bin/conda
2025-01-06 11:04:26.940 [info] Conda environment manager found at: /opt/mepy37/bin/conda
2025-01-06 11:04:26.944 [info] Conda environment manager found at: /home/********/yonatanr/.conda/envs/hello-world/bin/conda
2025-01-06 11:04:26.953 [info] Python interpreter path: /home/********/yonatanr/.conda/envs/hello-world/bin/python
2025-01-06 11:04:27.115 [info] > conda info --json
2025-01-06 11:04:27.115 [info] shell: zsh
2025-01-06 11:04:27.521 [info] Native locator: Refresh finished in 4099 ms
2025-01-06 11:04:27.815 [info] > conda run -n base --no-capture-output python ~/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/python_files/get_output_via_markers.py ~/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/python_files/printEnvVariables.py
2025-01-06 11:04:27.815 [info] shell: zsh
2025-01-06 11:04:28.580 [info] > python ~/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/python_files/printEnvVariables.py
2025-01-06 11:04:28.580 [info] shell: zsh
2025-01-06 11:04:28.603 [info] Setting environment variable XML_CATALOG_FILES in collection to file:///usr/local/conda/etc/xml/catalog file:///etc/xml/catalog {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2025-01-06 11:04:28.603 [info] Setting environment variable CONDA_ROOT in collection to /usr/local/conda {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2025-01-06 11:04:28.603 [info] Setting environment variable CONDA_PREFIX in collection to /usr/local/conda {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2025-01-06 11:04:28.604 [info] Setting environment variable CONDA_PROMPT_MODIFIER in collection to (base)  {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2025-01-06 11:04:28.604 [info] Setting environment variable CONDA_SHLVL in collection to 1 {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2025-01-06 11:04:28.604 [info] Setting environment variable CONDA_DEFAULT_ENV in collection to base {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2025-01-06 11:04:28.604 [info] Prepending environment variable PATH in collection with /usr/local/conda/bin: {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2025-01-06 11:04:28.604 [info] Send text to terminal: python /homes/yonatanr/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/python_files/printEnvVariablesToFile.py /homes/yonatanr/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/python_files/deactivate/zsh/envVars.txt
2025-01-06 11:04:37.702 [info] Starting Pylance language server.

Extension version: 2024.22.1
VS Code version: Code 1.96.2 (fabdb6a30b49f79a7aba0f2ad9df9b399473380f, 2024-12-19T10:22:47.216Z)
OS version: Windows_NT x64 10.0.22631
Modes:
Remote OS version: Linux x64 5.15.0-88-generic

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


languageServer: "Pylance"

Installed Extensions
Extension Name Extension Id Version
Better Jinja samuelcolvin.jinjahtml 0.20.0
Black Formatter ms-python.black-formatter 2024.4.0
Docker ms-azuretools.vscode-docker 1.29.3
Even Better TOML tamasfe.even-better-toml 0.21.2
Git Graph mhutchie.git-graph 1.30.0
GitHub Copilot GitHub.copilot 1.254.0
GitHub Copilot Chat GitHub.copilot-chat 0.23.2
gitignore codezombiech.gitignore 0.9.0
JavaScript Debugger ms-vscode.js-debug 1.96.0
Jupyter ms-toolsai.jupyter 2024.11.0
Jupyter Cell Tags ms-toolsai.vscode-jupyter-cell-tags 0.1.9
Jupyter Notebook Renderers ms-toolsai.jupyter-renderers 1.0.21
Jupyter Slide Show ms-toolsai.vscode-jupyter-slideshow 0.1.6
Pylance ms-python.vscode-pylance 2024.12.1
Python ms-python.python 2024.22.1
Python Debugger ms-python.debugpy 2024.14.0
Ruff charliermarsh.ruff 2024.56.0
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.10
YAML redhat.vscode-yaml 1.15.0
System Info
Item Value
CPUs Intel(R) Core(TM) Ultra 7 155U (14 x 2688)
GPU Status 2d_canvas: enabled
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
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 31.47GB (9.45GB free)
Process Argv --crash-reporter-id 1dc974f1-6d26-4a5d-bfde-4e1201df6930
Screen Reader no
VM 0%
Item Value
Remote SSH: ubup993
OS Linux x64 5.15.0-88-generic
CPUs Intel(R) Xeon(R) Gold 6354 CPU @ 3.00GHz (4 x 0)
Memory (System) 31.34GB (28.29GB free)
VM 100%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythonnoceb:30805159
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupytercf:31046870
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc1:31192215
cf971741:31144450
iacca1:31171482
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624

Image
Image
Image

EDIT:
I think it is somehow related to the fact I have a conda bin installed in the hello-world env. It was installed as a dependency of the conda-build package I installed there.

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jan 6, 2025
@karthiknadig
Copy link
Member

Duplicate of microsoft/python-environment-tools#184

@yonaroz You identified the issue correctly. This occuress due to nested conda. Workaround is to use python.locator as js. The native locator is a new locator that we are switching to, it seems to detect environments that have conda in it as base

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

2 participants