Python3 project remove __pycache__ folders and .pyc files

SalientGreen picture SalientGreen · Mar 11, 2015 · Viewed 128.5k times · Source

What is the BEST way to clear out all the __pycache__ folders and .pyc/.pyo files from a python3 project. I have seen multiple users suggest the pyclean script bundled with Debian, but this does not remove the folders. I want a simple way to clean up the project before pushing the files to my DVS.

Answer

V. Gamula picture V. Gamula · Jun 5, 2015

You can do it manually with the next command:

find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf

This will remove all *.pyc files and __pycache__ directories recursively in the current directory.