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 does not activate my ".conda" environment that is selected as "Current Interpreter" #24472

Closed
jpfeuffer opened this issue Nov 21, 2024 · 37 comments
Assignees
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster needs PR Ready to be worked on

Comments

@jpfeuffer
Copy link

Type: Bug

Behaviour

When I open a new zsh terminal in VSCode, although I activated "activateActiveEnvironmentInTerminal" (or how this settings is called), it only loads the conda base environment.
My .conda environment in the same folder is correctly selected and displayed in the lower right corner of VSCode. And I can activate it easily with conda activate ./.conda

Steps to reproduce:

  1. Activate "activateActiveEnvironmentInTerminal" in settings
  2. Select interpreter
  3. New environment
  4. Select .conda
  5. Create it
  6. Open a new Terminal and hope it gets activated.

The problem is that you command tried to run conda -n .conda and not conda -p .conda. This is a PREFIX environment not a NAMED environment..

Diagnostic data

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

2024-11-21 13:05:03.417 [error] getActivatedEnvironmentVariables Error: Command failed: conda run -n .conda --no-capture-output python /Users/x/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/get_output_via_markers.py /Users/x/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/printEnvVariables.py

EnvironmentLocationNotFound: Not a conda environment: /Users/x/miniforge3/envs/.conda


    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at ChildProcess.exithandler (node:child_process:423:12)
    at ChildProcess.emit (node:events:531:35)
    at maybeClose (node:internal/child_process:1105:16)
    at Socket.<anonymous> (node:internal/child_process:457:11)
    at Socket.emit (node:events:519:28)
    at Pipe.<anonymous> (node:net:339:12) {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'conda run -n .conda --no-capture-output python /Users/x/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/get_output_via_markers.py /Users/x/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/printEnvVariables.py'
}

Extension version: 2024.20.0
VS Code version: Code 1.95.3 (Universal) (f1a4fb101478ce6ec82fe9627c43efbf9e98c813, 2024-11-13T14:50:04.152Z)
OS version: Darwin arm64 23.6.0
Modes:

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


venvPath: "<placeholder>"

languageServer: "Pylance"

Installed Extensions
Extension Name Extension Id Version
Actionforge Graph Editor Actionforge.actionforge 0.9.84
autoDocstring - Python Docstring Generator njpwerner.autodocstring 0.6.1
Better C++ Syntax jeff-hykin.better-cpp-syntax 1.27.1
Black Formatter ms-python.black-formatter 2024.4.0
Browse Lite antfu.browse-lite 0.3.9
C/C++ ms-vscode.cpptools 1.22.11
C/C++ Extension Pack ms-vscode.cpptools-extension-pack 1.3.0
C/C++ Themes ms-vscode.cpptools-themes 2.0.0
carbon-now-sh ericadamski.carbon-now-sh 1.2.0
clangd llvm-vs-code-extensions.vscode-clangd 0.1.31
CMake twxs.cmake 0.0.17
CMake Test Explorer fredericbonnet.cmake-test-adapter 0.17.4
CMake Tools ms-vscode.cmake-tools 1.19.52
cmake-format cheshirekow.cmake-format 0.6.11
CodeLLDB vadimcn.vscode-lldb 1.11.1
CodeWhisperer for command line amazonwebservices.codewhisperer-for-command-line-companion 0.1.0
Data Wrangler ms-toolsai.datawrangler 1.12.1
Dev Containers ms-vscode-remote.remote-containers 0.388.0
Docker ms-azuretools.vscode-docker 1.29.3
Doxygen Documentation Generator cschlosser.doxdocgen 1.4.0
Even Better TOML tamasfe.even-better-toml 0.19.2
Flake8 ms-python.flake8 2023.10.0
GitHub Actions github.vscode-github-actions 0.27.0
GitHub Copilot GitHub.copilot 1.245.1221
GitHub Copilot Chat GitHub.copilot-chat 0.23.2024102903
GitHub Markdown Preview bierner.github-markdown-preview 0.3.0
Gitpod gitpod.gitpod-desktop 0.0.180
HashiCorp Terraform hashicorp.terraform 2.34.0
HTML CSS Support ecmel.vscode-html-css 2.0.11
isort ms-python.isort 2023.10.1
JavaScript Debugger ms-vscode.js-debug 1.95.3
JavaScript Debugger Companion Extension ms-vscode.js-debug-companion 1.1.3
Jupyter ms-toolsai.jupyter 2024.10.0
Jupyter Keymap ms-toolsai.jupyter-keymap 1.1.2
Jupyter Notebook Renderers ms-toolsai.jupyter-renderers 1.0.21
Just pilot lrh3321.just2 2.0.2
Learn Vim vintharas.learn-vim 0.0.28
Markdown Checkboxes bierner.markdown-checkbox 0.4.0
Markdown Emoji bierner.markdown-emoji 0.3.0
Markdown Footnotes bierner.markdown-footnotes 0.1.1
Markdown Preview for Github Alerts yahyabatulu.vscode-markdown-alert 0.0.4
Markdown Preview Github Styling bierner.markdown-preview-github-styles 2.1.0
Markdown Preview Mermaid Support bierner.markdown-mermaid 1.27.0
Markdown yaml Preamble bierner.markdown-yaml-preamble 0.1.0
markdownlint DavidAnson.vscode-markdownlint 0.57.0
Mojo 🔥 modular-mojotools.vscode-mojo 24.5.5
New Syntax Highlighter fallenwood.syntax-highlighter-ng 0.6.0
Nextflow nextflow.nextflow 1.0.1
Open in GitHub fabiospampinato.vscode-open-in-github 2.3.0
Pylance ms-python.vscode-pylance 2024.11.2
Python ms-python.python 2024.20.0
Python Debugger ms-python.debugpy 2024.12.0
Python Envy teticio.python-envy 0.1.8
Python Sphinx Highlighter leonhard-s.python-sphinx-highlight 0.3.0
Rainbow CSV mechatroner.rainbow-csv 3.12.0
Remote - SSH ms-vscode-remote.remote-ssh 0.115.1
Remote - SSH: Editing Configuration Files ms-vscode-remote.remote-ssh-edit 0.87.0
Remote Development ms-vscode-remote.vscode-remote-extensionpack 0.26.0
rust 1YiB.rust-bundle 1.0.0
Rust Syntax dustypomerleau.rust-syntax 0.6.1
rust-analyzer rust-lang.rust-analyzer 0.3.2188
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.10
Test Adapter Converter ms-vscode.test-adapter-converter 0.2.1
Test Explorer UI hbenl.vscode-test-explorer 2.22.1
Trusty Rusty Snippets polypus74.trusty-rusty-snippets 0.0.5
Vim vscodevim.vim 1.28.1
Vite antfu.vite 0.2.5
WSL ms-vscode-remote.remote-wsl 0.88.5
yapf eeyore.yapf 2024.9.126091437
System Info
Item Value
CPUs Apple M2 Max (12 x 2400)
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
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 2, 3, 3
Memory (System) 64.00GB (19.55GB free)
Process Argv --crash-reporter-id 6ff5cf85-0c6d-49ba-b87f-c0bb6780000d
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
jg8ic977:31013176
dvdeprecation:31068756
dwnewjupyter:31046869
nativerepl1:31139838
pythonrstrctxt:31112756
cf971741:31144450
iacca1:31171482
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Nov 21, 2024
@karthiknadig
Copy link
Member

@jpfeuffer Can you share the exact setting you are using (i.e., can you share the settings.json content)? Python extension only has the following settings for activation:
python.terminal.activateEnvInCurrentTerminal
python.terminal.activateEnvironment

We detect prefixed vs named environments, so it should use the correct command.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Nov 25, 2024
@jpfeuffer
Copy link
Author

jpfeuffer commented Nov 25, 2024

Now it doesn't even try to find my environment anymore. I don't get any logs of your extension trying to set my .conda environment...

My only python settings are:

"python.venvPath": "....../pypoetry/virtualenvs",
"python.analysis.typeCheckingMode": "basic",

python.terminal.activateEnvInCurrentTerminal is ON by default as far as I can see.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Nov 25, 2024
@jpfeuffer
Copy link
Author

I tried with and without python.terminal.activateEnvInCurrentTerminal. Both do not work.

@jpfeuffer
Copy link
Author

Ok, so with python locator = js it just does nothing.
With python locator = native I get the error from my initial report.

In summary: nothing works.

@jpfeuffer
Copy link
Author

You do detect prefixed environments for stuff like pylance, but not for activation in the shell.

@cividis
Copy link

cividis commented Nov 25, 2024

I encountered the same issue too, which only started occurring for me this morning.

When I open a new terminal, I have to manually activate the environment with conda activate ./.conda. When I run the current line or file, it does use the .conda/bin/python, however.

My settings.json is as follows:

{
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnSave": true
    },
    "terminal.integrated.inheritEnv": false,
    "editor.minimap.enabled": false,
    "python.terminal.activateEnvInCurrentTerminal": true, // just added, but no effect
    "python.terminal.activateEnvironment": true // just added, but no effect
}

@karthiknadig
Copy link
Member

Can you try version 2024.16.1 or 2024.14.1 and see if they behave better? This will help narrow down the problem. Locally I am not able to repo this.
You can switch version using the ⚙️icon from the extension view and selecting "install specific version":
Image

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Nov 26, 2024
@karthiknadig karthiknadig self-assigned this Nov 26, 2024
@cividis
Copy link

cividis commented Nov 26, 2024

@karthiknadig I can confirm the problem persists on both versions (I was originally using v2024.14.1, and just tested v2024.16.1).

@cividis
Copy link

cividis commented Dec 1, 2024

I ended up creating a new Conda environment outside of VSCode (e.g., conda create --name myenv python=3.10 in Terminal), and then selecting this interpreter with Python: Select Interpreter in the Command Palette pane. Now when I open terminal, the Conda environment is selected. I apologize I couldn't be more helpful </3

@jpfeuffer
Copy link
Author

But this is a named environment. I want my environment in the development folder of my vscode project (under .conda).
This is not a satisfying solution.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Dec 1, 2024
@Duoquote
Copy link

Duoquote commented Dec 3, 2024

I just come accross with same behavior now, I am using path environments with conda, it used to activate like conda activate C:\somedir\myenv but right now the behavior looks like changed to conda activate myenv, which is really not the correct way to activate path environments.

Image

Image

Not sure when it got changed because I opted out of vscode updates because of breaking changes, I do update at some occasions to get new features on a spare time.

EDIT: Looks like some things have changed since v2024.10.0:

  • v2024.10.0: Works fine, but looks like it activates conda using activate instead of full path like C:/Users/duoquote/miniforrge3/Scripts/activate which is the current behavior.
  • v2024.12.0: Doesn't activate environment at all, not even base environment.
  • v2024.12.1: Same broken path activation as I mentioned in this comment.
  • ...
  • v2024.20.0: Still broken
  • v2024.21.2024112901 (pre-release): Still broken

@karthiknadig
Copy link
Member

This might be a bug in new discovery code. I am investigating. Try changing the value of “Python.locator” setting from “js” to “native”.

I will share a build to try after I have a fix.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Dec 3, 2024
@Duoquote
Copy link

Duoquote commented Dec 3, 2024

changing the value of “Python.locator” setting from “js” to “native”

Did not work for me with v2024.20.0.

@crasylph
Copy link

crasylph commented Dec 4, 2024

I encountered the same issue, and it is resolved by switching to v2024.10.0.
I've tried v2024.20.0, 16.1, 14.1 and 12.3, and the issue appears in them all.

@karthiknadig karthiknadig added the bug Issue identified by VS Code Team member as probable bug label Dec 4, 2024
@mattflowers-8451
Copy link

I am having this same issue. I have noticed it specifically when using a conda environment created using --path instead of --name. From the extension logs, it looks like the integrated terminal is trying to using --name for things even if the environment was created with a path (which happens by default when creating a new conda environment through the command pallette)

EnvironmentLocationNotFound: Not a conda environment: /opt/homebrew/Caskroom/miniconda/base/envs/.conda


    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at ChildProcess.exithandler (node:child_process:423:12)
    at ChildProcess.emit (node:events:531:35)
    at maybeClose (node:internal/child_process:1105:16)
    at Socket.<anonymous> (node:internal/child_process:457:11)
    at Socket.emit (node:events:519:28)
    at Pipe.<anonymous> (node:net:339:12) {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'conda run -n .conda --no-capture-output python /Users/*********/.vscode/extensions/ms-python.python-2024.21.2024112901/python_files/get_output_via_markers.py /Users/*********/.vscode/extensions/ms-python.python-2024.21.2024112901/python_files/printEnvVariables.py'
}

For me .conda is a directory at the root of my project

@zoulee24
Copy link

zoulee24 commented Dec 7, 2024

same issue

@zoulee24
Copy link

zoulee24 commented Dec 7, 2024

This might be a bug in new discovery code. I am investigating. Try changing the value of “Python.locator” setting from “js” to “native”.

I will share a build to try after I have a fix.

after switching Python.locator option from native to js and then switch js to native, issue fixed by plugin itself. very confuse.

previous issues output. python plugin version 2024.16.1 and 2024.20.0

2024-12-07 20:01:08.694 [error] getActivatedEnvironmentVariables [Error: Command failed: /home/pw/miniconda3/bin/conda run -n .conda --no-capture-output python /home/pw/.vscode-server/extensions/ms-python.python-2024.16.1-linux-x64/python_files/get_output_via_markers.py /home/pw/.vscode-server/extensions/ms-python.python-2024.16.1-linux-x64/python_files/printEnvVariables.py

EnvironmentLocationNotFound: Not a conda environment: /home/pw/miniconda3/envs/.conda


	at genericNodeError (node:internal/errors:984:15)
	at wrappedFn (node:internal/errors:538:14)
	at ChildProcess.exithandler (node:child_process:422:12)
	at ChildProcess.emit (node:events:531:35)
	at maybeClose (node:internal/child_process:1105:16)
	at ChildProcess._handle.onexit (node:internal/child_process:305:5)] {
  code: 1,
  killed: false,
  signal: null,
  cmd: '/home/pw/miniconda3/bin/conda run -n .conda --no-capture-output python /home/pw/.vscode-server/extensions/ms-python.python-2024.16.1-linux-x64/python_files/get_output_via_markers.py /home/pw/.vscode-server/extensions/ms-python.python-2024.16.1-linux-x64/python_files/printEnvVariables.py'
}

@thomasruegg
Copy link

thomasruegg commented Dec 7, 2024

Same issue, works again when downgrading to v2024.10.0, thanks @Duoquote

@karthiknadig
Copy link
Member

@karthiknadig karthiknadig removed info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team labels Dec 7, 2024
@karthiknadig karthiknadig added area-environments Features relating to handling interpreter environments needs PR Ready to be worked on info-needed Issue requires more information from poster labels Dec 7, 2024
@Pa3ckP7
Copy link

Pa3ckP7 commented Dec 7, 2024

Popping in here as I noticed having this issue as well. And i also found that reverting to 2024.10 fixed the issue. As for the builds linked by @karthiknadig

2024-12-07 22:45:29.903 [info] Experiment 'pythonRecommendTensorboardExt' is active
2024-12-07 22:45:29.904 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2024-12-07 22:45:29.904 [info] Experiment 'pythonTestAdapter' is active
2024-12-07 22:45:29.904 [info] Native locator: Refresh started
2024-12-07 22:45:29.916 [info] Conda environment manager found at: C:\ProgramData\miniconda3\Scripts\conda.exe
2024-12-07 22:45:29.933 [info] Native locator: Refresh finished in 444 ms
2024-12-07 22:45:30.535 [info] > C:\ProgramData\miniconda3\Scripts\conda.exe info --json
2024-12-07 22:45:30.547 [info] > pyenv which python
2024-12-07 22:45:30.547 [info] cwd: ~\Desktop\R1p3r Bot
2024-12-07 22:45:32.823 [info] Python interpreter path: .\.conda\python.exe
2024-12-07 22:45:33.130 [info] > C:\ProgramData\miniconda3\Scripts info --json
2024-12-07 22:45:33.131 [info] shell: powershellCore
2024-12-07 22:45:33.544 [info] > conda info --json
2024-12-07 22:45:33.544 [info] shell: powershellCore
2024-12-07 22:45:34.256 [info] Starting Pylance language server.
2024-12-07 22:45:34.436 [info] > C:\ProgramData\miniconda3\Scripts\conda.exe info --json
2024-12-07 22:45:34.436 [info] shell: powershellCore
2024-12-07 22:45:36.619 [info] > C:\ProgramData\miniconda3\condabin\conda.bat info --json
2024-12-07 22:45:36.619 [info] shell: powershellCore
2024-12-07 22:45:38.801 [info] > C:\ProgramData\miniconda3\Scripts\conda.exe run -n .conda --no-capture-output python ~\.vscode\extensions\ms-python.python-2024.21.0-dev\python_files\get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py
2024-12-07 22:45:38.801 [info] shell: powershellCore
2024-12-07 22:45:40.155 [error] getActivatedEnvironmentVariables [Error: Command failed: C:\ProgramData\miniconda3\Scripts\conda.exe run -n .conda --no-capture-output python c:\Users\pa3ck\.vscode\extensions\ms-python.python-2024.21.0-dev\python_files\get_output_via_markers.py c:/Users/pa3ck/.vscode/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py

EnvironmentLocationNotFound: Not a conda environment: C:\Users\pa3ck\.conda\envs\.conda


	at genericNodeError (node:internal/errors:984:15)
	at wrappedFn (node:internal/errors:538:14)
	at ChildProcess.exithandler (node:child_process:423:12)
	at ChildProcess.emit (node:events:531:35)
	at maybeClose (node:internal/child_process:1105:16)
	at ChildProcess._handle.onexit (node:internal/child_process:305:5)] {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'C:\\ProgramData\\miniconda3\\Scripts\\conda.exe run -n .conda --no-capture-output python c:\\Users\\pa3ck\\.vscode\\extensions\\ms-python.python-2024.21.0-dev\\python_files\\get_output_via_markers.py c:/Users/pa3ck/.vscode/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py'
}
2024-12-07 22:45:40.162 [info] > C:\ProgramData\miniconda3\Scripts info --json
2024-12-07 22:45:40.162 [info] shell: commandPrompt
2024-12-07 22:45:40.192 [info] > conda info --json
2024-12-07 22:45:40.193 [info] shell: commandPrompt
2024-12-07 22:45:40.225 [info] > C:\ProgramData\miniconda3\Scripts\conda.exe info --json
2024-12-07 22:45:40.225 [info] shell: commandPrompt
2024-12-07 22:45:42.188 [info] > C:\ProgramData\miniconda3\condabin\conda.bat info --json
2024-12-07 22:45:42.188 [info] shell: commandPrompt
2024-12-07 22:45:44.110 [info] > C:\ProgramData\miniconda3\Scripts\conda.exe run -n .conda --no-capture-output python ~\.vscode\extensions\ms-python.python-2024.21.0-dev\python_files\get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py
2024-12-07 22:45:44.110 [info] shell: commandPrompt
2024-12-07 22:45:45.262 [error] getActivatedEnvironmentVariables [Error: Command failed: C:\ProgramData\miniconda3\Scripts\conda.exe run -n .conda --no-capture-output python c:\Users\pa3ck\.vscode\extensions\ms-python.python-2024.21.0-dev\python_files\get_output_via_markers.py c:/Users/pa3ck/.vscode/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py

EnvironmentLocationNotFound: Not a conda environment: C:\Users\pa3ck\.conda\envs\.conda


	at genericNodeError (node:internal/errors:984:15)
	at wrappedFn (node:internal/errors:538:14)
	at ChildProcess.exithandler (node:child_process:423:12)
	at ChildProcess.emit (node:events:531:35)
	at maybeClose (node:internal/child_process:1105:16)
	at ChildProcess._handle.onexit (node:internal/child_process:305:5)] {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'C:\\ProgramData\\miniconda3\\Scripts\\conda.exe run -n .conda --no-capture-output python c:\\Users\\pa3ck\\.vscode\\extensions\\ms-python.python-2024.21.0-dev\\python_files\\get_output_via_markers.py c:/Users/pa3ck/.vscode/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py'
}

@karthiknadig
Copy link
Member

@Pa3ckP7 I am not able to repo this with the build I gave you. This is what I see:

2024-12-08 06:02:13.374 [info] Experiment 'pythonRecommendTensorboardExt' is active
2024-12-08 06:02:13.374 [info] Experiment 'pythonSurveyNotification' is active
2024-12-08 06:02:13.374 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2024-12-08 06:02:13.374 [info] Experiment 'pythonTestAdapter' is active
2024-12-08 06:02:13.374 [info] Native locator: Refresh started
2024-12-08 06:02:13.840 [info] > pyenv which python
2024-12-08 06:02:13.840 [info] cwd: .
2024-12-08 06:02:14.033 [info] Conda environment manager found at: C:\ProgramData\miniconda3\Scripts\conda.exe
2024-12-08 06:02:14.216 [info] > C:\ProgramData\miniconda3\Scripts\conda.exe info --json
2024-12-08 06:02:14.256 [info] Native locator: Refresh finished in 1972 ms
2024-12-08 06:02:20.944 [info] Python interpreter path: .\.conda\python.exe
2024-12-08 06:02:20.982 [info] > C:\ProgramData\miniconda3\condabin\conda.bat info --json
2024-12-08 06:02:20.983 [info] shell: powershell
2024-12-08 06:02:47.827 [info] > C:\ProgramData\miniconda3\condabin\conda.bat run -p .\.conda --no-capture-output python "c:\GIT\s p\vscode-python\python_files\get_output_via_markers.py" "c:/GIT/s p/vscode-python/python_files/printEnvVariables.py"
2024-12-08 06:02:47.827 [info] shell: powershell
2024-12-08 06:02:48.854 [info] Starting Jedi language server for pygls.

would it be possible to share the output of conda info --json, one more thing can you try Python: Clear cache and reload before trying again with that build?

@Pa3ckP7
Copy link

Pa3ckP7 commented Dec 8, 2024

Ran the Clear cache and reload window and i am appending the conda info below. It didn't work for some reason it still thinks it's a named environment. I don't got named environments apart from base as i use path based ones

conda-info.json

@Pa3ckP7
Copy link

Pa3ckP7 commented Dec 9, 2024

Ok Update on this. The extension installed with VSIX works for my air-farming, but not for HCI or R1p3r. Which is quite a bit odd

EDIT: I compared settings between air-farming and r1p3r. And apart from one being a workspace and the other not. Do discernable difference. I tried creating a workspace with same setting as air-famring in r1p3r, but that was not the issue

@karthiknadig
Copy link
Member

karthiknadig commented Dec 9, 2024

@zoulee24
Copy link

zoulee24 commented Dec 10, 2024 via email

@zoulee24
Copy link

zoulee24 commented Dec 11, 2024

@Pa3ckP7 I have another version with bit more logging, and a bit of logic improvements. Can you try this, and share the logs?

win32-x64: https://github.com/microsoft/vscode-python/actions/runs/12236450388/artifacts/2293834228 win32-arm64: https://github.com/microsoft/vscode-python/actions/runs/12236450388/artifacts/2293834227 linux-x64: https://github.com/microsoft/vscode-python/actions/runs/12236450388/artifacts/2293834224 alpine-x64: https://github.com/microsoft/vscode-python/actions/runs/12236450388/artifacts/2293834221

@karthiknadig Switching to this version seems to solve the problem. Here is the log after switching to your version.

2024-12-11 21:36:19.852 [info] Experiment 'pythonRecommendTensorboardExt' is active
2024-12-11 21:36:19.852 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2024-12-11 21:36:19.852 [info] Experiment 'pythonTestAdapter' is active
2024-12-11 21:36:19.852 [info] Native locator: Refresh started
2024-12-11 21:36:19.852 [info] Conda environment manager found at: /home/pw/miniconda3/bin/conda
2024-12-11 21:36:19.852 [info] Conda env is --prefix environment: /home/pw/code/zgy/CrowdCounting-P2PNet/.conda
2024-12-11 21:36:19.876 [info] Native locator: Refresh finished in 176 ms
2024-12-11 21:36:20.263 [info] > pyenv which python
2024-12-11 21:36:20.263 [info] cwd: .
2024-12-11 21:36:20.471 [info] > ~/miniconda3/bin/conda info --json
2024-12-11 21:36:20.937 [info] Conda env is --prefix environment: /home/pw/code/zgy/CrowdCounting-P2PNet/.conda
2024-12-11 21:36:20.939 [info] Python interpreter path: ./.conda/bin/python
2024-12-11 21:36:20.969 [info] > ~/miniconda3 info --json
2024-12-11 21:36:20.969 [info] shell: bash
2024-12-11 21:36:21.006 [info] > conda info --json
2024-12-11 21:36:21.006 [info] shell: bash
2024-12-11 21:36:21.010 [info] > ~/.conda/bin/conda info --json
2024-12-11 21:36:21.011 [info] shell: bash
2024-12-11 21:36:21.014 [info] > ~/.condarc/bin/conda info --json
2024-12-11 21:36:21.014 [info] shell: bash
2024-12-11 21:36:21.018 [info] > ~/Miniconda3-latest-Linux-x86_64.sh/bin/conda info --json
2024-12-11 21:36:21.018 [info] shell: bash
2024-12-11 21:36:21.022 [info] > ~/miniconda3/bin/conda info --json
2024-12-11 21:36:21.022 [info] shell: bash
2024-12-11 21:36:21.523 [info] > ~/miniconda3/bin/conda run -p ./.conda --no-capture-output python ~/.vscode-server/extensions/ms-python.python-2024.21.0-dev/python_files/get_output_via_markers.py ~/.vscode-server/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py
2024-12-11 21:36:21.523 [info] shell: bash
2024-12-11 21:36:22.393 [info] > /bin/python3 ~/.vscode-server/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py
2024-12-11 21:36:22.393 [info] shell: bash
2024-12-11 21:36:22.409 [info] Setting environment variable CONDA_EXE in collection to /home/pw/miniconda3/bin/conda {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 21:36:22.409 [info] Setting environment variable _CE_M in collection to  {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 21:36:22.409 [info] Setting environment variable CONDA_ROOT in collection to /home/pw/miniconda3 {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 21:36:22.409 [info] Setting environment variable CONDA_PREFIX in collection to /home/pw/code/zgy/CrowdCounting-P2PNet/.conda {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 21:36:22.409 [info] Setting environment variable CONDA_PROMPT_MODIFIER in collection to (/home/pw/code/zgy/CrowdCounting-P2PNet/.conda)  {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 21:36:22.409 [info] Setting environment variable _CE_CONDA in collection to  {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 21:36:22.409 [info] Setting environment variable CONDA_SHLVL in collection to 2 {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 21:36:22.409 [info] Setting environment variable CONDA_PYTHON_EXE in collection to /home/pw/miniconda3/bin/python {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 21:36:22.409 [info] Setting environment variable CONDA_DEFAULT_ENV in collection to /home/pw/code/zgy/CrowdCounting-P2PNet/.conda {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 21:36:22.409 [info] Prepending environment variable PATH in collection with /home/pw/code/zgy/CrowdCounting-P2PNet/.conda/bin:/home/pw/miniconda3/condabin: {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 21:36:22.409 [info] Setting environment variable CONDA_PREFIX_1 in collection to /home/pw/miniconda3 {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 21:36:22.409 [info] Prepending environment variable PS1 in collection with (.conda)  {"applyAtShellIntegration":true,"applyAtProcessCreation":false}
2024-12-11 21:36:22.410 [info] Send text to terminal: /bin/python3 /home/pw/.vscode-server/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariablesToFile.py /home/pw/.vscode-server/extensions/ms-python.python-2024.21.0-dev/python_files/deactivate/bash/envVars.txt
2024-12-11 21:36:31.434 [info] Starting Pylance language server.

@Pa3ckP7
Copy link

Pa3ckP7 commented Dec 11, 2024

@karthiknadig sorry for late reply here is your more debugging thing

2024-12-11 22:08:16.152 [info] Experiment 'pythonRecommendTensorboardExt' is active
2024-12-11 22:08:16.152 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2024-12-11 22:08:16.152 [info] Experiment 'pythonTestAdapter' is active
2024-12-11 22:08:16.152 [info] Native locator: Refresh started
2024-12-11 22:08:16.152 [info] Conda environment manager found at: C:\ProgramData\miniconda3\Scripts\conda.exe
2024-12-11 22:08:16.158 [info] Native locator: Refresh finished in 498 ms
2024-12-11 22:08:16.774 [info] Native locator: Refresh started
2024-12-11 22:08:16.814 [info] Conda environment manager found at: C:\ProgramData\miniconda3\Scripts\conda.exe
2024-12-11 22:08:16.880 [info] > C:\ProgramData\miniconda3\Scripts\conda.exe info --json
2024-12-11 22:08:16.899 [info] > pyenv which python
2024-12-11 22:08:16.899 [info] cwd: ~\Desktop\R1p3r Bot
2024-12-11 22:08:16.987 [info] Native locator: Refresh finished in 214 ms
2024-12-11 22:08:19.382 [info] Python interpreter path: .\.conda\python.exe
2024-12-11 22:08:19.692 [info] > C:\ProgramData\miniconda3\Scripts info --json
2024-12-11 22:08:19.692 [info] shell: powershellCore
2024-12-11 22:08:20.114 [info] > conda info --json
2024-12-11 22:08:20.114 [info] shell: powershellCore
2024-12-11 22:08:20.770 [info] Starting Pylance language server.
2024-12-11 22:08:20.973 [info] > C:\ProgramData\miniconda3\Scripts\conda.exe info --json
2024-12-11 22:08:20.973 [info] shell: powershellCore
2024-12-11 22:08:23.111 [info] > C:\ProgramData\miniconda3\condabin\conda.bat info --json
2024-12-11 22:08:23.111 [info] shell: powershellCore
2024-12-11 22:08:25.225 [info] > C:\ProgramData\miniconda3\Scripts\conda.exe run -n .conda --no-capture-output python ~\.vscode\extensions\ms-python.python-2024.21.0-dev\python_files\get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py
2024-12-11 22:08:25.225 [info] shell: powershellCore
2024-12-11 22:08:26.494 [error] getActivatedEnvironmentVariables [Error: Command failed: C:\ProgramData\miniconda3\Scripts\conda.exe run -n .conda --no-capture-output python c:\Users\pa3ck\.vscode\extensions\ms-python.python-2024.21.0-dev\python_files\get_output_via_markers.py c:/Users/pa3ck/.vscode/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py

EnvironmentLocationNotFound: Not a conda environment: C:\Users\pa3ck\.conda\envs\.conda


	at genericNodeError (node:internal/errors:984:15)
	at wrappedFn (node:internal/errors:538:14)
	at ChildProcess.exithandler (node:child_process:423:12)
	at ChildProcess.emit (node:events:530:35)
	at maybeClose (node:internal/child_process:1104:16)
	at ChildProcess._handle.onexit (node:internal/child_process:304:5)] {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'C:\\ProgramData\\miniconda3\\Scripts\\conda.exe run -n .conda --no-capture-output python c:\\Users\\pa3ck\\.vscode\\extensions\\ms-python.python-2024.21.0-dev\\python_files\\get_output_via_markers.py c:/Users/pa3ck/.vscode/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py'
}
2024-12-11 22:08:26.501 [info] > C:\ProgramData\miniconda3\Scripts info --json
2024-12-11 22:08:26.501 [info] shell: commandPrompt
2024-12-11 22:08:26.528 [info] > conda info --json
2024-12-11 22:08:26.529 [info] shell: commandPrompt
2024-12-11 22:08:26.564 [info] > C:\ProgramData\miniconda3\Scripts\conda.exe info --json
2024-12-11 22:08:26.564 [info] shell: commandPrompt
2024-12-11 22:08:28.460 [info] > C:\ProgramData\miniconda3\condabin\conda.bat info --json
2024-12-11 22:08:28.460 [info] shell: commandPrompt
2024-12-11 22:08:30.464 [info] > C:\ProgramData\miniconda3\Scripts\conda.exe run -n .conda --no-capture-output python ~\.vscode\extensions\ms-python.python-2024.21.0-dev\python_files\get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py
2024-12-11 22:08:30.464 [info] shell: commandPrompt
2024-12-11 22:08:31.547 [error] getActivatedEnvironmentVariables [Error: Command failed: C:\ProgramData\miniconda3\Scripts\conda.exe run -n .conda --no-capture-output python c:\Users\pa3ck\.vscode\extensions\ms-python.python-2024.21.0-dev\python_files\get_output_via_markers.py c:/Users/pa3ck/.vscode/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py

EnvironmentLocationNotFound: Not a conda environment: C:\Users\pa3ck\.conda\envs\.conda


	at genericNodeError (node:internal/errors:984:15)
	at wrappedFn (node:internal/errors:538:14)
	at ChildProcess.exithandler (node:child_process:423:12)
	at ChildProcess.emit (node:events:530:35)
	at maybeClose (node:internal/child_process:1104:16)
	at ChildProcess._handle.onexit (node:internal/child_process:304:5)] {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'C:\\ProgramData\\miniconda3\\Scripts\\conda.exe run -n .conda --no-capture-output python c:\\Users\\pa3ck\\.vscode\\extensions\\ms-python.python-2024.21.0-dev\\python_files\\get_output_via_markers.py c:/Users/pa3ck/.vscode/extensions/ms-python.python-2024.21.0-dev/python_files/printEnvVariables.py'
}

@Pa3ckP7
Copy link

Pa3ckP7 commented Dec 11, 2024

Ok small noteworthy update js locator correctly detected it to be a path not a named environment. Bug appears to be with the native locator as the js locator works fine even on the new 2024.22 build

@mieszkomularczyk
Copy link

I confirm the switching Python.locator to: native->js-native fixes the problem also in plugin version 2024.22.0

This might be a bug in new discovery code. I am investigating. Try changing the value of “Python.locator” setting from “js” to “native”.
I will share a build to try after I have a fix.

after switching Python.locator option from native to js and then switch js to native, issue fixed by plugin itself. very confuse.

previous issues output. python plugin version 2024.16.1 and 2024.20.0

2024-12-07 20:01:08.694 [error] getActivatedEnvironmentVariables [Error: Command failed: /home/pw/miniconda3/bin/conda run -n .conda --no-capture-output python /home/pw/.vscode-server/extensions/ms-python.python-2024.16.1-linux-x64/python_files/get_output_via_markers.py /home/pw/.vscode-server/extensions/ms-python.python-2024.16.1-linux-x64/python_files/printEnvVariables.py

EnvironmentLocationNotFound: Not a conda environment: /home/pw/miniconda3/envs/.conda


	at genericNodeError (node:internal/errors:984:15)
	at wrappedFn (node:internal/errors:538:14)
	at ChildProcess.exithandler (node:child_process:422:12)
	at ChildProcess.emit (node:events:531:35)
	at maybeClose (node:internal/child_process:1105:16)
	at ChildProcess._handle.onexit (node:internal/child_process:305:5)] {
  code: 1,
  killed: false,
  signal: null,
  cmd: '/home/pw/miniconda3/bin/conda run -n .conda --no-capture-output python /home/pw/.vscode-server/extensions/ms-python.python-2024.16.1-linux-x64/python_files/get_output_via_markers.py /home/pw/.vscode-server/extensions/ms-python.python-2024.16.1-linux-x64/python_files/printEnvVariables.py'
}

@karthiknadig
Copy link
Member

Try pre-release version 2024.23 that has the fix for this.

via #24553

@mieszkomularczyk
Copy link

mieszkomularczyk commented Dec 12, 2024

Hello @karthiknadig ,
Unfortunately the pre-release version is not solving this problem, but at least it tries. When I open a project with conda, I see the following in the termina. The symptioms are still the same, conda is activated for the vs studion runtime (if I run a python file, it works in the conda virtual env) but there is not activation in the terminal for command line. I wish it would work like 10 months ago.
For a time being the trick with native->js->native works in release version. BTW, I would not like to add conda.exe to the PATH like I did not have to do it in the past.

PS D:\Projects\ainotebook> C:/Users/miesz/miniconda3/Scripts/activate
PS D:\Projects\ainotebook> conda activate d:\Projects\ainotebook.conda
conda: The term 'conda' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

@karthiknadig
Copy link
Member

Re-opening the issue, since it doesn't look like it is addressed.

@karthiknadig karthiknadig reopened this Dec 12, 2024
@Pa3ckP7
Copy link

Pa3ckP7 commented Dec 12, 2024

For me native flat out doesn't work. If I am on JS it will work fine even with reloads. Native however won't work at all with reloads
Pre-Release version

@karthiknadig
Copy link
Member

karthiknadig commented Dec 12, 2024

Would it be possible to share the logs (Output > Python ), and the activation command used in both (js and native) cases? I am trying to figure out why the two behave differently, when they have the same info.

@Pa3ckP7
Copy link

Pa3ckP7 commented Dec 12, 2024

Here you go

Js locator
js-locator.txt

and
native locator
native-locator.txt

@mieszkomularczyk
Copy link

One comment about the native->js->native. One needs to rotate the change like that. And it works while the vs studio is running. Let me check if rotating this setting solves the problem persistenly (after restart of VSC)

@karthiknadig
Copy link
Member

Digging into this, I was able to repro it with v2024.23.2024121003

2024-12-12 22:24:11.275 [error] getActivatedEnvironmentVariables Error: Command failed: C:\ProgramData\miniconda3\condabin\conda.bat run -n .conda --no-capture-output python c:\Users\kanadig\.vscode-insiders\extensions\ms-python.python-2024.23.2024121003-win32-x64\python_files\get_output_via_markers.py c:/Users/kanadig/.vscode-insiders/extensions/ms-python.python-2024.23.2024121003-win32-x64/python_files/printEnvVariables.py

EnvironmentLocationNotFound: Not a conda environment: C:\Users\kanadig\.conda\envs\.conda

It seems to be fixed in v2024.23.2024121201:

2024-12-12 23:26:41.767 [info] > C:\ProgramData\miniconda3\condabin\conda.bat run -p "C:\GIT\TPI\dec2024\C0nda Repro\.conda" --no-capture-output python ~\.vscode-insiders\extensions\ms-python.python-2024.23.2024121201-win32-x64\python_files\get_output_via_markers.py ~/.vscode-insiders/extensions/ms-python.python-2024.23.2024121201-win32-x64/python_files/printEnvVariables.py
2024-12-12 23:26:41.767 [info] shell: powershell
2024-12-12 23:26:49.817 [info] > C:\Python311\python.exe ~/.vscode-insiders/extensions/ms-python.python-2024.23.2024121201-win32-x64/python_files/printEnvVariables.py

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 bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster needs PR Ready to be worked on
Projects
None yet
Development

No branches or pull requests

10 participants