Skip to content

Auto-activation of a conda environment not working #22856

Closed as not planned
Closed as not planned

Description

@ubalklen

Type: Bug

Behaviour

Expected vs. Actual

The new auto-activation environment scheme is not working here. If I run pip list, I can't see the packages that are installed in the virtual env. If I manually activate the environment, it works.

Steps to reproduce:

  1. Open a Python project that has an associated conda virtual env (myenv)
  2. Have a settings.json like this:
settings.json
{
    "terminal.integrated.profiles.windows": {
        "My PowerShell": {
            "source": "PowerShell",
            "args": [
                "-NoExit",
                "-Command",
                "C:\\Users\\[REDACTED]\\proxy.ps1"
            ]
        }
    },
    "terminal.integrated.defaultProfile.windows": "My PowerShell",
    "terminal.integrated.enableMultiLinePasteWarning": false,
    "workbench.startupEditor": "newUntitledFile",
    "workbench.editorAssociations": {"*.ipynb": "jupyter-notebook"},
    "workbench.iconTheme": "vscode-icons",
    "editor.minimap.enabled": false,
    "editor.rulers": [88],
    "explorer.confirmDragAndDrop": false,
    "explorer.confirmDelete": false,
    "git.enableSmartCommit": true,
    "git.confirmSync": false,
    "python.terminal.activateEnvInCurrentTerminal": true,
    "python.analysis.autoImportCompletions": false,
    "isort.args": ["--profile", "black"],
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnType": true,
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": "explicit"
        },
        "rewrap.autoWrap.enabled": true,
    },
    "[html]":{
        "editor.formatOnSave": true,
    },
    "jupyter.askForKernelRestart": false,
    "jupyter.widgetScriptSources": ["jsdelivr.com", "unpkg.com"],
    "git.mergeEditor": true,
    "diffEditor.maxComputationTime": 0,
    "liveServer.settings.donotVerifyTags": true,
    "liveServer.settings.donotShowInfoMsg": true,
    "diffEditor.ignoreTrimWhitespace": false,
    "http.proxySupport": "on",
    "jupyter.allowUnauthorizedRemoteConnection": true,
    "security.workspace.trust.untrustedFiles": "open",
    "http.proxyAuthorization": null,
    "python.defaultInterpreterPath": "C:\\Users\\[REDACTED]\\AppData\\Local\\miniconda3\\envs\\[REDACTED]\\python.exe",
    "http.proxy": "[REDACTED]",
    "editor.inlineSuggest.enabled": true,
    "powershell.promptToUpdatePowerShell": false,
    "git.openRepositoryInParentFolders": "never",
    "update.enableWindowsBackgroundUpdates": false,
    "redhat.telemetry.enabled": false,
    "workbench.colorTheme": "One Dark Modern",
}
  1. A cute message pops up reassuring me that I can safely ignore the (base) on the terminal and myenv is in fact activated...

thecakeisalie

  1. ...except that it's not. If i run pip list, I cannot see the packages that are installed in my target virtual env.
  2. I also couldn't import the missing packages from the python interpreter.
  3. If I manually run conda activate myenv, I got the expected (myenv) prompt and all works fine.
  4. Interestingly, if I debug a python script that imports packages that are only installed in myenv while in the (base) scenario, the script runs (no ImportError).

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.7
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

2024-02-06 09:19:06.402 [info] Experiment 'pythonRecommendTensorboardExt' is active
2024-02-06 09:19:06.403 [info] Experiment 'pythonREPLSmartSend' is active
2024-02-06 09:19:06.403 [info] Experiment 'pythonSurveyNotification' is active
2024-02-06 09:19:06.403 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2024-02-06 09:19:06.403 [info] Experiment 'pythonTestAdapter' is active
2024-02-06 09:19:06.403 [info] Default formatter is set to ms-python.black-formatter for workspace c:\Users\[REDACTED]
2024-02-06 09:19:06.403 [info] Test server listening.
2024-02-06 09:19:06.403 [info] Python interpreter path: ~\AppData\Local\miniconda3\envs\myenv\python.exe
2024-02-06 09:19:06.403 [info] Send text to terminal: echo C:\Program Files\PowerShell\7\pwsh.exe
2024-02-06 09:19:07.851 [info] > conda info --json
2024-02-06 09:19:08.427 [warning] Identifier for virt-virtualenv failed to identify d:\Code\[REDACTED]\.env\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir 'd:\Code\[REDACTED]\.env\Scripts'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'd:\\Code\\[REDACTED]\\.env\\Scripts'
}
2024-02-06 09:19:08.694 [info] Shell integration is not working for powershellCore
2024-02-06 09:19:08.696 [warning] Shell integration is not active, environment activated maybe overriden by the shell.
2024-02-06 09:19:08.699 [info] > conda info --json
2024-02-06 09:19:08.699 [info] shell: powershellCore
2024-02-06 09:19:09.072 [info] > "d:\Code\[REDACTED]\.env\Scripts\python.exe" -I ~\.vscode\extensions\ms-python.python-2024.0.0\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2024.0.0\pythonFiles\interpreterInfo.py
2024-02-06 09:19:11.377 [info] Starting Pylance language server.
2024-02-06 09:19:15.512 [error] Error: Command failed: "d:\Code\[REDACTED]\.env\Scripts\python.exe" -I c:\Users\[REDACTED]\.vscode\extensions\ms-python.python-2024.0.0\pythonFiles\get_output_via_markers.py c:\Users\[REDACTED]\.vscode\extensions\ms-python.python-2024.0.0\pythonFiles\interpreterInfo.py
'"d:\Code\[REDACTED]\.env\Scripts\python.exe"' n�o � reconhecido como um comando interno
ou externo, um programa oper�vel ou um arquivo em lotes.

    at ChildProcess.exithandler (node:child_process:431:12)
    at ChildProcess.emit (node:events:526:35)
    at maybeClose (node:internal/child_process:1091:16)
    at Process.onexit (node:internal/child_process:302:5) {
  code: 1,
  killed: false,
  signal: null,
  cmd: '"d:\\Code\\[REDACTED]\\.env\\Scripts\\python.exe" -I c:\\Users\\[REDACTED]\\.vscode\\extensions\\ms-python.python-2024.0.0\\pythonFiles\\get_output_via_markers.py c:\\Users\\[REDACTED]\\.vscode\\extensions\\ms-python.python-2024.0.0\\pythonFiles\\interpreterInfo.py'
}
2024-02-06 09:19:17.527 [info] > "d:\Code\[REDACTED]\.env\Scripts\python.exe" -I ~\.vscode\extensions\ms-python.python-2024.0.0\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2024.0.0\pythonFiles\interpreterInfo.py
2024-02-06 09:19:20.613 [error] Error: Command failed: "d:\Code\[REDACTED]\.env\Scripts\python.exe" -I c:\Users\[REDACTED]\.vscode\extensions\ms-python.python-2024.0.0\pythonFiles\get_output_via_markers.py c:\Users\[REDACTED]\.vscode\extensions\ms-python.python-2024.0.0\pythonFiles\interpreterInfo.py
'"d:\Code\[REDACTED]\.env\Scripts\python.exe"' n�o � reconhecido como um comando interno
ou externo, um programa oper�vel ou um arquivo em lotes.

    at ChildProcess.exithandler (node:child_process:431:12)
    at ChildProcess.emit (node:events:526:35)
    at maybeClose (node:internal/child_process:1091:16)
    at Socket.<anonymous> (node:internal/child_process:449:11)
    at Socket.emit (node:events:514:28)
    at Pipe.<anonymous> (node:net:323:12) {
  code: 1,
  killed: false,
  signal: null,
  cmd: '"d:\\Code\\[REDACTED]\\.env\\Scripts\\python.exe" -I c:\\Users\\[REDACTED]\\.vscode\\extensions\\ms-python.python-2024.0.0\\pythonFiles\\get_output_via_markers.py c:\\Users\\[REDACTED]\\.vscode\\extensions\\ms-python.python-2024.0.0\\pythonFiles\\interpreterInfo.py'
}
2024-02-06 09:19:25.912 [info] > conda run -n afpesp --no-capture-output python ~\.vscode\extensions\ms-python.python-2024.0.0\pythonFiles\get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.0.0/pythonFiles/printEnvVariables.py
2024-02-06 09:19:25.912 [info] shell: commandPrompt
2024-02-06 09:19:28.622 [info] > conda run -n afpesp --no-capture-output python ~\.vscode\extensions\ms-python.python-2024.0.0\pythonFiles\get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.0.0/pythonFiles/printEnvVariables.py
2024-02-06 09:19:28.622 [info] shell: powershellCore
2024-02-06 09:19:38.755 [info] > python ~/.vscode/extensions/ms-python.python-2024.0.0/pythonFiles/printEnvVariables.py
2024-02-06 09:19:38.755 [info] shell: powershellCore
2024-02-06 09:19:40.879 [info] Send text to terminal: & python c:\Users\[REDACTED]\.vscode\extensions\ms-python.python-2024.0.0\pythonFiles\printEnvVariablesToFile.py c:\Users\[REDACTED]\.vscode\extensions\ms-python.python-2024.0.0\pythonFiles\deactivate\powershell\envVars.txt

User Settings


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true

Extension version: 2024.0.0
VS Code version: Code 1.85.2 (8b3775030ed1a69b13e4f4c628c612102e30a681, 2024-01-18T06:40:10.514Z)
OS version: Windows_NT x64 10.0.19042
Modes:

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz (8 x 1498)
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 15.40GB (3.94GB free)
Process Argv --crash-reporter-id f02ec49e-7219-47e8-8815-4c59941e60c8
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vscorecescf:30445987
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:30899288
vscaat:30438848
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30951796
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
dsvsc019b:30953937
3ef8e399:30949928

Activity

  1. changed the title [-]Auto-activating conda environment not working[/-] [+]Auto-activation of a conda environment not working[/+] on Feb 6, 2024
  2. karrtikr commented on Feb 6, 2024

    @karrtikr

    2024-02-06 09:19:08.694 [info] Shell integration is not working for powershellCore
    2024-02-06 09:19:08.696 [warning] Shell integration is not active, environment activated maybe overriden by the shell.

    I think it's happening because of this issue which was just fixed: #22850, can you try out the latest pre-release version of the extension?

    image

  3. ubalklen commented on Feb 6, 2024

    @ubalklen
    Author

    Still not working, but at least there is no misleading message this time.

    Python output
    2024-02-06 14:51:17.432 [info] Experiment 'pythonRecommendTensorboardExt' is active
    2024-02-06 14:51:17.432 [info] Experiment 'pythonREPLSmartSend' is active
    2024-02-06 14:51:17.432 [info] Experiment 'pythonSurveyNotificationcf' is active
    2024-02-06 14:51:17.432 [info] Experiment 'pythonTerminalEnvVarActivation' is active
    2024-02-06 14:51:17.432 [info] Experiment 'pythonTestAdapter' is active
    2024-02-06 14:51:17.432 [info] Default formatter is set to ms-python.black-formatter for workspace c:\Users\[REDACTED]
    2024-02-06 14:51:17.432 [info] Test server listening.
    2024-02-06 14:51:17.432 [info] Python interpreter path: ~\AppData\Local\miniconda3\envs\[REDACTED]\python.exe
    2024-02-06 14:51:17.432 [info] > conda info --json
    2024-02-06 14:51:17.432 [info] shell: powershellCore
    2024-02-06 14:51:18.526 [info] > conda info --json
    2024-02-06 14:51:18.863 [warning] Identifier for virt-virtualenv failed to identify d:\[REDACTED]\.env\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir 'd:\[REDACTED]\.env\Scripts'] {
      errno: -4058,
      code: 'ENOENT',
      syscall: 'scandir',
      path: 'd:\\[REDACTED]\\.env\\Scripts'
    }
    2024-02-06 14:51:19.516 [info] > "d:\[REDACTED]\.env\Scripts\python.exe" -I ~\.vscode\extensions\ms-python.python-2024.1.10371009\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2024.1.10371009\pythonFiles\interpreterInfo.py
    2024-02-06 14:51:20.398 [error] Error: Command failed: "d:\[REDACTED]\.env\Scripts\python.exe" -I c:\Users\[REDACTED]\.vscode\extensions\ms-python.python-2024.1.10371009\pythonFiles\get_output_via_markers.py c:\Users\[REDACTED]\.vscode\extensions\ms-python.python-2024.1.10371009\pythonFiles\interpreterInfo.py
    '"d:\[REDACTED]\.env\Scripts\python.exe"' n�o � reconhecido como um comando interno
    ou externo, um programa oper�vel ou um arquivo em lotes.
    
        at ChildProcess.exithandler (node:child_process:431:12)
        at ChildProcess.emit (node:events:526:35)
        at maybeClose (node:internal/child_process:1091:16)
        at Socket.<anonymous> (node:internal/child_process:449:11)
        at Socket.emit (node:events:514:28)
        at Pipe.<anonymous> (node:net:323:12) {
      code: 1,
      killed: false,
      signal: null,
      cmd: '"d:\\[REDACTED]\\.env\\Scripts\\python.exe" -I c:\\Users\\[REDACTED]\\.vscode\\extensions\\ms-python.python-2024.1.10371009\\pythonFiles\\get_output_via_markers.py c:\\Users\\[REDACTED]\\.vscode\\extensions\\ms-python.python-2024.1.10371009\\pythonFiles\\interpreterInfo.py'
    }
    2024-02-06 14:51:22.011 [info] Starting Pylance language server.
    2024-02-06 14:51:22.468 [info] > "d:\[REDACTED]\.env\Scripts\python.exe" -I ~\.vscode\extensions\ms-python.python-2024.1.10371009\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2024.1.10371009\pythonFiles\interpreterInfo.py
    2024-02-06 14:51:29.350 [error] Error: Command failed: "d:\[REDACTED]\.env\Scripts\python.exe" -I c:\Users\[REDACTED]\.vscode\extensions\ms-python.python-2024.1.10371009\pythonFiles\get_output_via_markers.py c:\Users\[REDACTED]\.vscode\extensions\ms-python.python-2024.1.10371009\pythonFiles\interpreterInfo.py
    '"d:\[REDACTED]\.env\Scripts\python.exe"' n�o � reconhecido como um comando interno
    ou externo, um programa oper�vel ou um arquivo em lotes.
    
        at ChildProcess.exithandler (node:child_process:431:12)
        at ChildProcess.emit (node:events:526:35)
        at maybeClose (node:internal/child_process:1091:16)
        at Process.onexit (node:internal/child_process:302:5) {
      code: 1,
      killed: false,
      signal: null,
      cmd: '"d:\\[REDACTED]\\.env\\Scripts\\python.exe" -I c:\\Users\\[REDACTED]\\.vscode\\extensions\\ms-python.python-2024.1.10371009\\pythonFiles\\get_output_via_markers.py c:\\Users\\[REDACTED]\\.vscode\\extensions\\ms-python.python-2024.1.10371009\\pythonFiles\\interpreterInfo.py'
    }
    2024-02-06 14:51:30.513 [info] > conda run -n afpesp --no-capture-output python ~\.vscode\extensions\ms-python.python-2024.1.10371009\pythonFiles\get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.1.10371009/pythonFiles/printEnvVariables.py
    2024-02-06 14:51:30.513 [info] shell: commandPrompt
    2024-02-06 14:51:36.528 [info] > conda run -n afpesp --no-capture-output python ~\.vscode\extensions\ms-python.python-2024.1.10371009\pythonFiles\get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.1.10371009/pythonFiles/printEnvVariables.py
    2024-02-06 14:51:36.528 [info] shell: powershellCore
    2024-02-06 14:51:41.423 [info] > python ~/.vscode/extensions/ms-python.python-2024.1.10371009/pythonFiles/printEnvVariables.py
    2024-02-06 14:51:41.423 [info] shell: powershellCore
    2024-02-06 14:51:43.425 [info] Send text to terminal: & python c:\Users\[REDACTED]\.vscode\extensions\ms-python.python-2024.1.10371009\pythonFiles\printEnvVariablesToFile.py c:\Users\[REDACTED]\.vscode\extensions\ms-python.python-2024.1.10371009\pythonFiles\deactivate\powershell\envVars.txt
    
  4. karrtikr commented on Feb 7, 2024

    @karrtikr

    Great, we're getting closer. Can you please provide the debug logs?

    • Run Developer: Set log level command
    • Select Trace
    • Run Developer: Reload Window command
    • Provide the output:
    Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

    XXX
    

  5. piwawa commented on Feb 7, 2024

    @piwawa
  6. karrtikr commented on Feb 7, 2024

    @karrtikr
  7. piwawa commented on Feb 7, 2024

    @piwawa
  8. karrtikr commented on Feb 7, 2024

    @karrtikr
  9. piwawa commented on Feb 7, 2024

    @piwawa

    I see, glad you were able to solve it. Please feel free to let us know if there is anything we can do to assist you.

    I am fine now, still thank you for your kindness!

  10. brettcannon commented on Mar 13, 2024

    @brettcannon
    Member

    Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

  11. locked as resolved and limited conversation to collaborators on Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

experimentingFeature is part of an experimentinfo-neededIssue requires more information from postertriage-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