Skip to content

Virtual environment from an unrelated directory gets selected #21825

Closed as not planned
@brettcannon

Description

@brettcannon

Filed on behalf of @gvanrossum ...

Behaviour

Expected vs. Actual

When I open a repo directory (I use the command line: code ~/<dirname>/), a seemingly random venv gets activated. What I want is: either a venv with a standard name (e.g. 'venv' or '.venv') in that repo (whether or not it's managed by git) is activated, or possibly a venv with a standard name from my home directory (e.g. ~/venv or ~/.venv). But what I get is a venv in some other repo that I might have last opened days or weeks ago gets activated. And sometimes no venv gets activated. I don't know how to control what happens, which is probably the most frustrating part.

Steps to reproduce:

  1. Open VS Code on a repo, say ~/cpython.
  2. In the shell, type 'code ~/peps/'.
  3. In the new VS Code window that appears, create a shell window.
  4. Observe that in that shell window, another repo's venv is opened, say ~/devguide/venv/.

Diagnostic data

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

2023-08-15 15:29:54.747 [info] Experiment 'pythonPromptNewFormatterExt' is active
2023-08-15 15:29:54.747 [info] Experiment 'pythonPromptNewToolsExt' is active
2023-08-15 15:29:54.747 [error] Dir "/Users/guido/peps" is not watchable (too many files)
2023-08-15 15:29:54.747 [info] Test server listening.
2023-08-15 15:29:54.747 [info] Python interpreter path: ~/devguide/venv/bin/python
2023-08-15 15:29:56.776 [info] Starting Pylance language server.
2023-08-15 15:30:06.160 [info] Send text to terminal: source /Users/guido/devguide/venv/bin/activate

User Settings


languageServer: "Pylance"

Metadata

Metadata

Assignees

Labels

info-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