Venv Cleaner
A simple TUI/GUI tool for cleaning up old or unused Python virtual environments (venv directories).
How to Use
The easiest way to run in TUI mode is using uvx:
uvx venvcleaner
You can also run in GUI mode:
uvx --with wxpython venvcleaner
You can specify a target directory:
uvx venvcleaner /path/to/target-directory
TUI or GUI?
Venv Cleaner chooses the UI as follows:
- GUI mode when wxPython is installed,
--no-guiis not set, and a display is available. - TUI mode otherwise (including when you pass
--no-gui).
On Linux, if both DISPLAY and WAYLAND_DISPLAY are unset (typical for SSH sessions without display forwarding), Venv Cleaner runs in TUI mode even when wxPython is installed. You can also force TUI mode with --no-gui on any platform.
Using GUI mode on Linux
If you want to use GUI mode on Linux, you will need to build wxPython via pip. Please see Building wxPython for Linux via Pip and wxWidgets for GTK installation.
Alternatively, on some Linux systems, you can use the -f (--find-links) option to specify the download URL of wxPython package:
# for Ubuntu 24.04
uvx -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-24.04 \
--with wxpython==4.2.5 venvcleaner
Installing into a Persistent Environment
If you want to install Venv Cleaner into a persistent environment:
uv tool install "venvcleaner[gui]@latest"
# for Ubuntu 24.04
uv tool install -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-24.04 \
--with wxpython==4.2.5 venvcleaner@latest
# run Venv Cleaner (GUI when available, otherwise TUI)
venvcleaner
# force TUI mode
venvcleaner --no-gui
Features
- Scans the target directory recursively for virtual environments (directories containing a
pyvenv.cfgfile). - In TUI mode, you can change the target directory by editing the path field and pressing Enter, or refresh the scan with the Refresh button.
- In GUI mode, you can change or refresh the target directory with the Select... or Refresh buttons.
- Choose which venvs to clean using the selection list.
- Select All selects all detected venvs.
- Select None clears the selection.
- In TUI mode, press Space to toggle the current row. In GUI mode, use the multi-select list.
- Copy Paths (GUI) copies the paths of selected venvs to your clipboard. You can paste them into a terminal to run shell commands manually. For example:
ls /path/to/project-1/.venv "/path/to/project 2/.venv"
rm -r /path/to/project-1/.venv "/path/to/project 2/.venv"
- Dump Paths (TUI) prints the full paths of selected venvs to stdout, one per line, and exits. This is useful on SSH or other remote sessions where clipboard access is unavailable. For example:
venvcleaner --no-gui /path/to/scan # select venvs, then press Dump Paths
# /path/to/project-1/.venv
# /path/to/project-2/.venv
- Cleanup Venvs deletes the selected venv directories. In TUI mode, cleanup progress is briefly printed to the terminal, then the TUI resumes.
TUI Key Bindings
| Key | Action |
|---|---|
↑ / ↓ |
Move within the venv list |
Space |
Toggle selection of the current row |
Tab / Shift+Tab |
Move focus between widgets |
Enter |
Activate the focused button / confirm path input |
a |
Select All |
n |
Select None |
r |
Refresh |
d |
Dump Paths |
Esc / q |
Quit |
In modal dialogs, press Esc to close, or use the buttons. Click a column header to sort the list.
Environment Variables
TUI mode reads optional settings from:
~/.config/venvcleaner/.env
| Variable | Description |
|---|---|
TEXTUAL_THEME |
Textual theme name (for example textual-light, textual-dark, or ansi-dark). If unset or empty, the Textual default theme is used. |
Example:
mkdir -p ~/.config/venvcleaner
echo 'TEXTUAL_THEME=textual-light' > ~/.config/venvcleaner/.env
You can also set TEXTUAL_THEME in your shell environment. Existing environment variables take precedence over values in .env.
License
This software is distributed under the terms of the MIT License.
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 venvcleaner-0.2.0.tar.gz.
File metadata
- Download URL: venvcleaner-0.2.0.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fc28b788dd52134423539c091da8bd4943f9567baa94c1aef7f153326421c02
|
|
| MD5 |
c4ddadf6d3e8f69e4551b0477fb05fa4
|
|
| BLAKE2b-256 |
e1d8080555d60e24c196b928b4967e2dbd4fd68b9323e82af4c49c97e9c0962e
|
File details
Details for the file venvcleaner-0.2.0-py3-none-any.whl.
File metadata
- Download URL: venvcleaner-0.2.0-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49abef624c4d4b5c04745b367d15a7117935ff15fe21ad54dffd59cb6aeaeb0f
|
|
| MD5 |
4fc0c00fd7662ee590139ef647972074
|
|
| BLAKE2b-256 |
3742dd1c0e6de23f2b0f37160d69b4862a07d3b6ba65fd6c2bb554d01a76be70
|