Skip to main content

Tool to find and delete Python virtual environments to free up disk space

Project description

venvkiller

PyPI version Python versions License: MIT GitHub stars

A Python tool to find and delete Python virtual environments to free up disk space.

Inspiration: This project was inspired by npkill, which provides similar functionality for cleaning up node_modules folders in JavaScript/Node.js projects.

Why venvkiller?

Python developers often create many virtual environments during development, which can end up occupying gigabytes of disk space. venvkiller helps you:

  • Quickly identify all virtual environments on your system
  • See which ones are old or unused
  • Safely delete them to reclaim disk space
  • Avoid accidentally deleting environments that belong to active projects

Features

  • Comprehensive Scanning: Find all Python virtual environments on your system
  • Detailed Information: Display size, last modified date, and full path
  • Modern TUI Interface: Built with the Textual library for an elegant terminal UI
  • Easy Navigation: Cursor-based navigation for effortless selection
  • Sorting Capabilities: Sort environments by size, age, or other criteria
  • Visual Progress: Real-time progress indicators during scanning and deletion
  • Smart Age Detection: Color-coding by age (green=recent, yellow=old, red=very old)
  • Safe Deletion: Verify requirements.txt/poetry/pipenv files exist before deletion
  • Folder Access: Keyboard shortcut to open containing folder in file explorer
  • Detailed Info: Comprehensive information panel for selected environment
  • Space Management: Total disk space usage and potential savings statistics

Installation

pip install venvkiller

Usage

# Run the interactive TUI
venvkiller

# Run with a specific start directory
venvkiller --start-dir ~/projects

# Run with custom age thresholds (in days)
venvkiller --recent 14 --old 90

Command Line Options

Option Description
--start-dir, -d Directory to start searching from (default: home directory)
--recent, -r Days threshold for considering an environment recent (green)
--old, -o Days threshold for considering an environment old (red)
--version Show version and exit
--help Show help message and exit

Keyboard Shortcuts

Key Action
Arrow keys Navigate the list
Space Mark/unmark for deletion
'd' Delete marked environments
'o' Open containing folder
'q' Quit

Screenshots

venvkiller Main Screen

Development

To set up for development:

# Clone the repository
git clone https://github.com/LeomaiaJr/venvkiller.git
cd venvkiller

# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install in development mode
pip install -e ".[dev]"

# Run the development version
python -m venvkiller.cli

# Run tests
pytest tests/
# Or for more verbose output with coverage
pytest tests/ -v --cov=venvkiller

How It Works

venvkiller works by recursively scanning directories for Python virtual environments, which it identifies by looking for common markers like pyvenv.cfg, bin/activate, or Scripts/activate.bat. It analyzes each environment to determine:

  1. Size on disk
  2. Last modified date
  3. Python version
  4. Installed packages
  5. Whether the parent directory contains requirements files

This information helps you make informed decisions about which environments to keep and which to delete.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

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

venvkiller-1.0.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

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

venvkiller-1.0.0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file venvkiller-1.0.0.tar.gz.

File metadata

  • Download URL: venvkiller-1.0.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for venvkiller-1.0.0.tar.gz
Algorithm Hash digest
SHA256 103b3b7f8042eac61230e25f40250467859bbb7db178b2f909af021cce0fe6ec
MD5 05be47d054c92a0258ef88b12dc01fce
BLAKE2b-256 9ec9dd772d7b3e8fc9a0e5b5e1f7ae756b549e309349cd90f07e45bd272d3a73

See more details on using hashes here.

File details

Details for the file venvkiller-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: venvkiller-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for venvkiller-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e032ed8e66b03ff9e1ce73fbca920d774812398f7012d5cffcfbaf9b0717c279
MD5 d2bfa3fc1631f2377982afaf1ba93267
BLAKE2b-256 9e6f8004c752e0a432a17fb1b5fbde865713fbda793274e274180c894f275ab5

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