Skip to main content

Discover all Python virtual environments on your system

Project description

find-venvs (vf)

Discover and manage all Python virtual environments on your system — regardless of name, tool, or location.

$ vf list
Found 7 virtual environment(s) under /home/abhishek

╭────┬──────────────────┬───────────────────────────────────────┬────────┬────────────────╮
│ Name             │ Path                                  │ Type   │ Python Version │
├────┼──────────────────┼───────────────────────────────────────┼────────┼────────────────┤
│ .venv            │ /home/abhishek/projects/api/.venv     │ venv   │ 3.11.4         │
│ groot            │ /home/abhishek/projects/web/groot     │ venv   │ 3.10.12        │
│ base             │ /home/abhishek/miniconda3/envs/base   │ conda  │ 3.9.7          │
╰────┴──────────────────┴───────────────────────────────────────┴────────┴────────────────╯

Why find-venvs?

Every tool that creates virtual environments (python -m venv, virtualenv, conda, poetry, pipenv) only knows about the environments it created. There is no existing pip-installable tool that answers the simple question:

"Where are all the virtual environments on my machine?"

find-venvs detects venvs by their content (pyvenv.cfg for standard venvs, conda-meta/ for conda), not by name — so it finds .venv, venv, env, groot, or any arbitrary directory name.

Installation

pip install find-venvs

Requires Python 3.8+. Works on Linux, macOS, and Windows.

Windows note: The --system flag is not supported on Windows (no single filesystem root). Use --root C:\ or --root D:\ to scan a specific drive.

Commands

vf list — list all environments

vf list                        # scan home directory
vf list --root /some/dir       # scan a specific directory
vf list --system               # scan from filesystem root /
vf list --depth 4              # limit recursion depth (default: 8)
vf list --json                 # machine-readable JSON output

JSON output example:

[
  {
    "name": ".venv",
    "path": "/home/abhishek/projects/api/.venv",
    "type": "venv",
    "python_version": "3.11.4"
  }
]

vf info <name> — inspect a single environment

Shows disk size, installed package count, and last-modified time.

vf info .venv
vf info myenv --root /projects
╭─────────────────── .venv ───────────────────╮
│  Name          .venv                         │
│  Path          /home/abhishek/projects/.venv │
│  Type          venv                          │
│  Python        3.11.4                        │
│  Disk size     142.3 MB                      │
│  Packages      34                            │
│  Last modified 2024-11-20  14:32             │
╰──────────────────────────────────────────────╯

If multiple environments share the same name, vf info shows a numbered list and asks you to pick one.


vf clean — find orphaned environments

Lists environments whose parent directory has no project files (pyproject.toml, requirements.txt, .git, Makefile, etc.) — a strong signal the project was deleted and the venv is leftover.

vf clean
vf clean --root /projects

vf del <name> — delete an environment

vf del .venv                        # interactive confirmation
vf del .venv --yes                  # skip confirmation
vf del .venv --dry-run              # show what would be deleted, do nothing
vf del .venv --path /projects/api   # skip full scan, go directly to /projects/api/.venv

Flags:

Flag Short Description
--yes -y Skip the confirmation prompt
--dry-run -n Preview deletion without removing anything
--path DIR -p Parent directory of the venv — skips system scan

When multiple environments share the same name and --path is not given, vf del shows a numbered picker so you choose exactly which one to remove.


Global scan flags

All subcommands accept these flags:

Flag Short Default Description
--root DIR -r home directory Root directory to scan
--system off Scan from filesystem root /
--depth N -d 8 Maximum recursion depth

Library API

You can use the scanner directly in your own scripts:

from find_venvs import scan, VenvInfo
from pathlib import Path

for venv in scan(Path.home(), max_depth=6):
    print(venv.path, venv.venv_type, venv.python_version)

scan() yields VenvInfo dataclass instances:

@dataclass
class VenvInfo:
    path: Path
    venv_type: str          # "venv" | "conda"
    python_version: str | None

How detection works

Signal Detected as
pyvenv.cfg present in directory venv (works for python -m venv, virtualenv, poetry, pipenv)
conda-meta/ directory present conda

Detection is purely content-based — the directory can have any name.

Directories known to never contain user venvs are skipped automatically: node_modules, .git, __pycache__, /proc, /sys, /dev, .cache, snap, and more. Symlinks are never followed.


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

find_venvs-0.2.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

find_venvs-0.2.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file find_venvs-0.2.0.tar.gz.

File metadata

  • Download URL: find_venvs-0.2.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for find_venvs-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5bde0a290997bd7c4f3e1d9a1d5dda4e1e778823f84a7dbf0d428e0bb214566c
MD5 e1f73d1d86addcdc1558f57f57f9f552
BLAKE2b-256 7fa93919465f3fd469dc597061f77e89dae609257de8c94742bc9bcb64734116

See more details on using hashes here.

File details

Details for the file find_venvs-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: find_venvs-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for find_venvs-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 531a1b150bd1fe0f9a73f4f6df14b459372f03bda63dc833b412b51a49a5e5df
MD5 3f19c29e1dc54afb6a37426205db7052
BLAKE2b-256 a22fc89c4ab38306b1a9d42d5de636a02add62e4b0f616e8c2159ea3147b32aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page