Skip to content

conda env can not be autoactivated #24637

Closed as not planned
Closed as not planned

Description

@Momo-ProMax

Type: Bug

linux Ubuntu or fedora, default setting.
from python log, we can know python tool have not correctly handle the conda env path "./.conda":

###
conda run -n .conda --no-capture-output python ~/.vscode/extensions/ms-python.python-2024.22.0-linux-x64/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.22.0-linux-x64/python_files/printEnvVariables.py
2024-12-18 22:15:36.443 [info] shell: bash
2024-12-18 22:15:37.130 [error] getActivatedEnvironmentVariables [Error: Command failed: conda run -n .conda --no-capture-output python /home/bat/.vscode/extensions/ms-python.python-2024.22.0-linux-x64/python_files/get_output_via_markers.py /home/bat/.vscode/extensions/ms-python.python-2024.22.0-linux-x64/python_files/printEnvVariables.py

EnvironmentLocationNotFound: Not a conda environment: /home/bat/miniconda3/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: 'conda run -n .conda --no-capture-output python /home/bat/.vscode/extensions/ms-python.python-2024.22.0-linux-x64/python_files/get_output_via_markers.py /home/bat/.vscode/extensions/ms-python.python-2024.22.0-linux-x64/python_files/printEnvVariables.py'
}
###

I have try to turn on or off terminal.integrated.inheritEnv, that will change the base path between "/" and "/miniconda3/envs/", but both of them were incorrect.

Extension version: 2024.22.0
VS Code version: Code 1.96.0 (138f619c86f1199955d53b4166bef66ef252935c, 2024-12-11T02:29:09.626Z)
OS version: Linux x64 6.8.0-51-generic
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.11
  • 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
开发容器 ms-vscode-remote.remote-containers 0.394.0
C/C++ ms-vscode.cpptools 1.22.11
Chinese (Simplified) (简体中文) Language Pack for Visual Studio Code MS-CEINTL.vscode-language-pack-zh-hans 1.96.2024121109
JavaScript Debugger ms-vscode.js-debug 1.96.0
JavaScript Debugger Companion Extension ms-vscode.js-debug-companion 1.1.3
Pylance ms-python.vscode-pylance 2024.12.1
Python ms-python.python 2024.22.0
Python Debugger ms-python.debugpy 2024.14.0
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.10
System Info
Item Value
CPUs Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz (8 x 3300)
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: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off
Load (avg) 2, 1, 1
Memory (System) 7.60GB (3.68GB free)
Process Argv --crash-reporter-id 663d0b4e-cd70-4d7e-919f-c2e2d648c154
Screen Reader no
VM 0%
DESKTOP_SESSION ubuntu
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP ubuntu
XDG_SESSION_TYPE x11
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
vscaac:30438847
c4g48928:30535728
azure-dev_surveyone:30548225
vscrp:30673768
962ge761:30959799
pythonnoceb:30805159
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupytercf:31046870
2f103344:31071589
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc1:31192215
cf971741:31144450
iacca1:31171482
notype1:31157159
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624

Activity

  1. karthiknadig commented on Dec 19, 2024

    @karthiknadig
    Member

    @SESProMax Can you share the logs from Output>Python?

  2. Momo-ProMax commented on Dec 19, 2024

    @Momo-ProMax
    Author

    Karthik Nadig (@karthiknadig)
    2024-12-19 22:57:53.234 [info] 试验“pythonRecommendTensorboardExt”处于活动状态
    2024-12-19 22:57:53.234 [info] 试验“pythonTerminalEnvVarActivation”处于活动状态
    2024-12-19 22:57:53.234 [info] 试验“pythonTestAdapter”处于活动状态
    2024-12-19 22:57:53.234 [info] Native locator: Refresh started
    2024-12-19 22:57:53.234 [info] Native locator: Refresh started
    2024-12-19 22:57:53.240 [info] Conda environment manager found at: /home/bat/miniconda3/bin/conda
    2024-12-19 22:57:54.520 [info] > pyenv which python
    2024-12-19 22:57:54.521 [info] cwd: .
    2024-12-19 22:57:54.556 [info] Native locator: Refresh finished in 1770 ms
    2024-12-19 22:57:55.523 [info] Python 解释器路径: ./.conda/bin/python
    2024-12-19 22:57:55.628 [info] > conda info --json
    2024-12-19 22:57:55.629 [info] shell: bash
    2024-12-19 22:57:56.937 [info] 正在启动 Pylance 语言服务器。
    2024-12-19 22:57:57.174 [info] > conda run -n .conda --no-capture-output python ~/.vscode/extensions/ms-python.python-2024.22.0-linux-x64/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.22.0-linux-x64/python_files/printEnvVariables.py
    2024-12-19 22:57:57.175 [info] shell: bash
    2024-12-19 22:57:58.154 [error] getActivatedEnvironmentVariables [Error: Command failed: conda run -n .conda --no-capture-output python /home/bat/.vscode/extensions/ms-python.python-2024.22.0-linux-x64/python_files/get_output_via_markers.py /home/bat/.vscode/extensions/ms-python.python-2024.22.0-linux-x64/python_files/printEnvVariables.py

    EnvironmentLocationNotFound: Not a conda environment: /home/bat/miniconda3/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: 'conda run -n .conda --no-capture-output python /home/bat/.vscode/extensions/ms-python.python-2024.22.0-linux-x64/python_files/get_output_via_markers.py /home/bat/.vscode/extensions/ms-python.python-2024.22.0-linux-x64/python_files/printEnvVariables.py'
    }

  3. karthiknadig commented on Dec 19, 2024

    @karthiknadig
    Member

    @SESProMax Please try the pre-release version of Python extension it has a fix for this bug. You can do this from the extension view, just click on "Switch to pre-release version"

    Image

  4. Momo-ProMax commented on Dec 19, 2024

    @Momo-ProMax
    Author

    @SESProMax Please try the pre-release version of Python extension it has a fix for this bug. You can do this from the extension view, just click on "Switch to pre-release version"

    Image

    thanks, that's worked.

  5. Momo-ProMax commented on Jan 1, 2025

    @Momo-ProMax
    Author

    @SESProMax Please try the pre-release version of Python extension it has a fix for this bug. You can do this from the extension view, just click on "Switch to pre-release version"

    Image

    Hello, Its me again. There is still the same problem, but on windows this time.

    2025-01-01 19:03:04.336 [error] getActivatedEnvironmentVariables [Error: Command failed: C:\Users\BAT\miniconda3\Scripts\conda.exe run -n .conda --no-capture-output python c:\Users\BAT\.vscode\extensions\ms-python.python-2024.22.1-win32-x64\python_files\get_output_via_markers.py c:/Users/BAT/.vscode/extensions/ms-python.python-2024.22.1-win32-x64/python_files/printEnvVariables.py
    
    EnvironmentLocationNotFound: Not a conda environment: C:\Users\BAT\miniconda3\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:\\Users\\BAT\\miniconda3\\Scripts\\conda.exe run -n .conda --no-capture-output python c:\\Users\\BAT\\.vscode\\extensions\\ms-python.python-2024.22.1-win32-x64\\python_files\\get_output_via_markers.py c:/Users/BAT/.vscode/extensions/ms-python.python-2024.22.1-win32-x64/python_files/printEnvVariables.py'
    }
    
  6. Momo-ProMax commented on Jan 1, 2025

    @Momo-ProMax
    Author

    Karthik Nadig (@karthiknadig) Changing the version of the Python extension or the shell does not make any difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bugtriage-neededNeeds assignment to the proper sub-team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions