Tool to find and delete Python virtual environments to free up disk space
Project description
venvkiller
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
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:
- Size on disk
- Last modified date
- Python version
- Installed packages
- 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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
103b3b7f8042eac61230e25f40250467859bbb7db178b2f909af021cce0fe6ec
|
|
| MD5 |
05be47d054c92a0258ef88b12dc01fce
|
|
| BLAKE2b-256 |
9ec9dd772d7b3e8fc9a0e5b5e1f7ae756b549e309349cd90f07e45bd272d3a73
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e032ed8e66b03ff9e1ce73fbca920d774812398f7012d5cffcfbaf9b0717c279
|
|
| MD5 |
d2bfa3fc1631f2377982afaf1ba93267
|
|
| BLAKE2b-256 |
9e6f8004c752e0a432a17fb1b5fbde865713fbda793274e274180c894f275ab5
|