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.3.0.tar.gz (12.0 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.3.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: find_venvs-0.3.0.tar.gz
  • Upload date:
  • Size: 12.0 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.3.0.tar.gz
Algorithm Hash digest
SHA256 0854edae1315f647409284171e86a3bd216d41fb96f7508b6a1d6fc778de0475
MD5 397bd28a092235d2825ac882ee5bd4d0
BLAKE2b-256 44af586378def60304f79fd95f2b37db0b04d0d5e36baed6642e7a635f13e32f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: find_venvs-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.0 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02c185f02dd54c9dd4cc3f803e02b538acbf2f608a7b67ec7e8139beb57784e9
MD5 56ce1a8d97658df5fe58322154d7f82f
BLAKE2b-256 840868f4e34b888cc65f0e6ca3f48ef2936afc11d15e071ca3197f69e7d781ab

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