Skip to content

Refreshing packages conflict with local script to remove venv #2054

Backlog

Description

@marcel-22

Problem

We have custom scripts to build and clean (remove) the virtual environment. When we clean the virtual environment, the vscode-python-environments extension notices this and starts examing it using command:
.venv\Scripts\python.exe -m pip list --format=json --not-required --disable-pip-version-check.

The venv is being deleted, so this causes to abort our script with an error:
rm: cannot remove '../app/.venv/Lib/site-packages/pip/_internal/utils/misc.py': Device or resource busy

At the same time the extensions reports an error: Error refreshing packages (Source: Python Environments).

Suggested fix

I noticed there is a setting python-envs.packageWatchers. This fixes the issue, but is only allowed as a user setting. I want it to be configurable as a workspace setting, so anyone who works with this workspace doesn't have to set a user setting on their own.

Environment data

  • Python Environments extension version: 1.44.0
  • Python extension (ms-python.python) version: 2026.10.0
  • VS Code version (Help → About): 1.142.0
  • OS and version: Windows 11 (Version 10.0.26200.9911)
  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.9
  • Environment manager in use (venv / conda / pyenv / poetry / pipenv / system / uv / other): pip in the scripts
  • Shell (bash / zsh / fish / pwsh / cmd / other): pwsh and bash
  • Remote / container scenario (none / WSL / SSH Remote / Dev Container / Codespaces): none
  • Workspace type (single folder / multi-root / mono-repo): multi-root, but probably also single folder
  • Is this a regression? If yes, last known working extension version: no

Activity

  1. marcel-22 commented on Nov 25, 2026

    @marcel-22
    Author

    The extension not only conflicts when removing the venv, but also when building the venv. The output from the extension shows that it runs: python: c:\Data\...\app\.venv\Scripts\python.exe: No module named pip. Of course, this is a timing related issue.

    The suggested fix solves this problem as well. Or at least, is a good workaroung for us.

  2. marcel-22 commented on Nov 25, 2026

    @marcel-22
    Author

    By the way: Is there a possibility to disable the virtual environments extension as a whole for a workspace? The python.useEnvironmentsExtension is just a temporary setting and is also not configurable as a workspace setting either. Suppose, if more issues are coming up, I'd like to be able to just disable the extension and do activation in the terminal ourselves. It is not working properly. Newly opened PowerShell terminals in a multi-root workspace are not activated for instance.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions