skillfed

pyclean

Pure Python cross-platform pyclean. Clean up your Python bytecode.

pyclean v3.7.0 645.6K downloads/30d#5,598 on PyPI91
Copyleft license GPL-3.0-or-later Active released

What it is and what it does

PyClean is a command-line utility that removes Python bytecode artifacts (.pyc files and __pycache__ directories) from your project tree in a single, cross-platform command. It addresses the common problem of bytecode clutter that accumulates during development, especially when switching between Python versions or working across different operating systems. Unlike shell commands like `rm` or `find`, PyClean provides a safe, intentional interface with options for dry-run preview, verbose output, and interactive confirmation.

Beyond bytecode cleanup, PyClean can optionally remove debris from popular development tools (pytest, coverage, ruff, mypy, tox, and others) in their default locations, detect and remove empty directories left after refactoring, and integrate with Git's `git clean` command. It supports globbing for arbitrary file deletion with safety constraints to prevent accidental data loss. The tool is actively maintained, supports modern Python versions (3.9–3.14), runs on both CPython and PyPy, and has no runtime dependencies.

Use it for:

  • Clean bytecode before committing to version control to avoid merge conflicts from .pyc file changes.
  • Remove accumulated __pycache__ directories and tool caches after switching Python versions or development environments.
  • Integrate into tox or CI/CD pipelines as a pre-test cleanup step via the --debris flag.
  • Safely delete arbitrary project files using glob patterns with the --erase option and dry-run preview.
  • Detect and remove empty directories left behind after code refactoring with the --folders flag.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Removes Python bytecode files (.pyc) and __pycache__ directories across your project in a single command, with optional cleanup of tool debris and empty directories.

Yes. PyClean solves a genuine cross-platform problem with zero dependencies, active maintenance, and a clear safety-first design. The copyleft license is a minor consideration for development tools but not a blocker for most projects. Install it if you work in multi-version Python environments or want a safer alternative to shell commands for bytecode cleanup.

Install

pyclean on PyPI

pip

pip install pyclean

uv

uv add pyclean

poetry

poetry add pyclean

Installing pyclean

Before you install

Low friction install with no runtime dependencies. Actively maintained as of 2026-05-23 with 91 repository stars. Supports Python 3.9 through 3.14 and both CPython and PyPy implementations.

License in practice

Licensed under GPL-3.0-or-later (copyleft). Requires derivative works and modifications to be distributed under the same license; suitable for development tools but check your project's licensing compatibility before integrating.

Quickstart

pip install pyclean
pyclean --help
pyclean -v .

Requires Python 3.9 or later. Git must be installed if using the --git-clean feature.

Verify before relying

  • Whether the --erase option's safety constraints (no recursive deletion by default, interactive confirmation) are sufficient for production use cases.
  • Performance characteristics when cleaning very large project trees or deeply nested directory structures.

Package facts

License GPL-3.0-or-later (copyleft)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 83 days since the last release
Last repo commit
First released
Downloads 645,611/month — #5,598 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pyclean-3.7.0-py3-none-any.whl

Keywords: python, bytecode, cli, tools

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Utilities

Tags

remove pyc filesclean python bytecodedelete pycache directoriespython cleanup toolcross-platform bytecode cleanerremove __pycache__python project cleanup
cli-tooldevelopment-utilities

More Utilities packages