Skip to main content

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

TUI mode

You can also run in GUI mode:

uvx --with wxpython venvcleaner

GUI mode

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-gui is 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.cfg file).
  • 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

venvcleaner-0.2.0.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

venvcleaner-0.2.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

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

Hashes for venvcleaner-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9fc28b788dd52134423539c091da8bd4943f9567baa94c1aef7f153326421c02
MD5 c4ddadf6d3e8f69e4551b0477fb05fa4
BLAKE2b-256 e1d8080555d60e24c196b928b4967e2dbd4fd68b9323e82af4c49c97e9c0962e

See more details on using hashes here.

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

Hashes for venvcleaner-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 49abef624c4d4b5c04745b367d15a7117935ff15fe21ad54dffd59cb6aeaeb0f
MD5 4fc0c00fd7662ee590139ef647972074
BLAKE2b-256 3742dd1c0e6de23f2b0f37160d69b4862a07d3b6ba65fd6c2bb554d01a76be70

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page