LinuxCommandLibrary

py3clean

TLDR

Clean Python 3 bytecode

$ py3clean [directory]
copy
Clean entire system
$ sudo py3clean -p [package]
copy
Dry run
$ py3clean -n [directory]
copy
Verbose output
$ py3clean -v [directory]
copy

SYNOPSIS

py3clean [options] directory|-p package

DESCRIPTION

py3clean removes Python 3 compiled bytecode files (.pyc) and _pycache_ directories. Part of Debian's python3-minimal package for system cleanup.

PARAMETERS

-p, --package package

Clean specific Debian package.
-v, --verbose
Verbose output.
-n, --dry-run
Show what would be deleted.
-q, --quiet
Quiet mode.

EXAMPLES

$ # Clean project directory
py3clean /path/to/project

# Clean installed package
sudo py3clean -p python3-requests

# Dry run first
py3clean -n /usr/lib/python3

# Verbose cleaning
py3clean -v ~/myproject

# Clean current directory
py3clean .
copy

WHAT IT REMOVES

$ *.pyc files
__pycache__/ directories
copy

CAVEATS

Debian/Ubuntu specific tool. Alternative: find . -name '*.pyc' -delete. Bytecode regenerates on next import.

HISTORY

py3clean is part of Debian's dh-python package for Python 3 packaging and cleanup.

SEE ALSO

Copied to clipboard