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

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

Closed
joyceerhl opened this issue Jan 30, 2024 · 2 comments · Fixed by #23642
Closed

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

joyceerhl opened this issue Jan 30, 2024 · 2 comments · Fixed by #23642
Labels
area-editor-* User-facing catch-all area-terminal feature-request Request for new features or functionality good first issue needs PR Ready to be worked on

Comments

@joyceerhl
Copy link

  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?

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

Looked at this with @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.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Jan 30, 2024
@karthiknadig karthiknadig removed the info-needed Issue requires more information from poster label Jan 30, 2024
@karrtikr
Copy link

karrtikr commented Feb 1, 2024

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"
],

@karrtikr karrtikr changed the title Virtual environment env vars not contributed for terminal in workspace containing venv if Python extension has not activated Activate Python extension if workspace containing .venv or .conda Feb 1, 2024
@karrtikr karrtikr added feature-request Request for new features or functionality area-terminal area-editor-* User-facing catch-all needs PR Ready to be worked on good first issue and removed triage-needed Needs assignment to the proper sub-team labels Feb 1, 2024
eleanorjboyd pushed a commit to eleanorjboyd/vscode-python that referenced this issue Jun 28, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-editor-* User-facing catch-all area-terminal feature-request Request for new features or functionality good first issue needs PR Ready to be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants