by Audrey M. Roy Greenfeld | Thu, Feb 20, 2025
How to remove stale .pyc files and __pycache__ directories, using uvx + pyclean.
I like to use the PyClean tool by Peter Bittner like this:
uvx pyclean .
This one-liner:
uvx
Here I run it on several of my git repos:
(uv) fun % uvx pyclean .
Cleaning directory .
Total 93 files, 34 directories removed.
uvx
is an alias for uv tool run
, part of the uv Python package manager.
It creates a single-use disposable virtualenv for whatever tool you install and run with it. Here the tool name matches the PyPI package name, but it does also support uvx <package-name>:<command-name>
.