Skip to content

Activate Python extension if workspace containing .venv or .conda #22814

Closed

Description

@joyceerhl
  1. Have a repo that contains a virtual environment
  2. Open it but do not open any Python files such that the Python extension is not activated
  3. Open a terminal
  4. 🐛 the virtual environment is not activated in the terminal and I have to manually activate the environment

Once the Python extension has activated at least once, it contributes those environment variables to the terminal, and VS Code caches those environment variables, so everything works on subsequent runs. Without that context though, the current behavior feels quite unpredictable. It feels like there is a missing activation event for the Python extension in this scenario. Maybe it could also activate on workspaceContains:.venv?

Activity

  1. added
    triage-needed
    on Jan 30, 2024
  2. karthiknadig commented on Jan 30, 2024

    @karthiknadig
    Member

    Looked at this with Joyce Er (@joyceerhl) . It feels odd that it works sometimes and it doesn't other times from the user perspective. I think we can try .venv and .conda patterns with the workspaceContains activation pattern.

  3. added
    info-needed
    on Jan 30, 2024
  4. removed
    info-needed
    on Jan 30, 2024
  5. karrtikr commented on Feb 1, 2024

    @karrtikr

    Looks like ".venv" or ".conda" patterns are missing in the activationEvents:

    "activationEvents": [
    "onDebugInitialConfigurations",
    "onLanguage:python",
    "onDebugResolve:python",
    "workspaceContains:mspythonconfig.json",
    "workspaceContains:pyproject.toml",
    "workspaceContains:Pipfile",
    "workspaceContains:setup.py",
    "workspaceContains:requirements.txt",
    "workspaceContains:manage.py",
    "workspaceContains:app.py"
    ],

  6. changed the title [-]Virtual environment env vars not contributed for terminal in workspace containing venv if Python extension has not activated[/-] on Feb 1, 2024
  7. added
    feature-request
    area-editor-*
    needs PR
    and removed
    triage-needed
    on Feb 1, 2024
  8. added a commit that references this issue on Jun 20, 2024
    043962c
  9. added a commit that references this issue on Jun 24, 2024
    29b708e
  10. added a commit that references this issue on Jun 28, 2024
    6a54d3b
  11. locked as resolved and limited conversation to collaborators on Jul 21, 2024
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

    area-editor-*area-terminalfeature-requestgood first issueneeds PR

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions