CMD + K

pyclean

Community

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

Installation

To install this package, run one of the following:

Conda
$conda install conda-forge::pyclean

Usage Tracking

3.4.0
3.3.0
3.2.0
3.1.0
3.0.0
5 / 8 versions selected
Downloads (Last 6 months): 0

Description

Worried about .pyc files and __pycache__ directories? Fear not! PyClean is here to help. Finally the single-command clean up for Python bytecode files in your favorite directories. On any platform.

pyclean .
pyclean . --dry-run --verbose
pyclean --help

PyClean can clean up leftovers, generated data and temporary files from popular Python development tools in their default locations, along with Python bytecode. The following topics are currently covered:

  • Cache (general purpose folder for several tools, e.g. Python eggs, legacy Pytest)
  • Coverage (coverage database, and supported file formats)
  • Packaging (build files and folders)
  • Pytest (build files and folders)
  • Ruff (ruff cache folder)
  • Jupyter (notebook checkpoints) – optional
  • Mypy (mypy cache folder) – optional
  • Pyright (pyright app cache folder) – optional
  • Tox (tox environments) – optional
pyclean . --debris
pyclean . --debris all
pyclean . -d jupyter -n -v

PyClean also lets you remove free-form targets using globbing. Note that this is potentially dangerous: You can delete everything anywhere in the file system, including the entire project you’re working on. For this reason, the --erase option has a few artificial constraints:

  • It doesn’t do recursive deletion by itself, which means that you have to specify the directory and its contents, separately and explicitly.
  • The above entails that you’re responsible for the deletion order, i.e. removal of a directory will only work if you asked to delete all files inside first.
  • You’re prompted interactively to confirm deletion, unless you specify the --yes option, in addition.
pyclean . --erase tmp/**/* tmp/

PyClean can safely detect and remove empty directories that are left in your project after refactoring code.

pyclean . --folders --verbose

PyClean integrates with Git's git clean command to remove untracked files from version-controlled directories. The --git-clean (or -g) flag runs after all other cleanup operations.

By default, Git prompts interactively to confirm which files to delete. Use --dry-run to preview, or --yes to force deletion without prompts. The --ignore patterns are honored as exclusions.

pyclean . --debris all --git-clean --dry-run
pyclean . --ignore .idea .vscode --git-clean --yes

Note: Git must be installed for this feature. If a directory is not under version control, a warning is logged and pyclean continues.

About

Summary

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

Last Updated

Nov 6, 2025 at 20:56

License

GPL-3.0-or-later

Total Downloads

44.7K

Supported Platforms

noarch