Feb 24, 2012

Delete all '.pyc' files recursively OS X


We often get strange errors with python. When you changing the source and cannot figure out why files are used from past. So if you ever get this dejavu feeling, try using this command:
find . -type f -name '*.pyc' -exec rm {} \;
It will delete all precompiled python sources. (Because with python you have ability to distribute your files in binaries in fact.) Those errors usually appear if you move/delete *.py files with version control. You usually exclude *.pyc files from list. Old links used this way. Debugger does not suggest wrong imports because your files are in fact there, just precompiled.
Anyway I've just put this command to my blog for memorizing. It often helps me. Maybe it can for you.