It seems that sometimes when I pull from the git the old .pyc
runs instead of the new pulled .py
file is there a way to automatically clear the .pyc
file so it runs always the fresh version ?
pyc files from a folder. You can use the find command (on OS X and Linux) to locate all of the . pyc files, and then use its delete option to delete them. Obviously, this can be used for any file type that you wish to eradicate, not just .
To remove Python compiled filesIn the Project tool window, right-click a project or directory, where Python compiled files should be deleted from. From the context menu, choose Clean Python compiled files. The . pyc and $py.
First finds all __pycache__ folders in current directory. Execute rm -r {} + to delete each folder at step above ( {} signify for placeholder and + to end the command)
__pycache__ is a folder containing Python 3 bytecode compiled and ready to be executed. I don't recommend routinely laboriously deleting these files or suppressing creation during development as it wastes your time.
The old .pyc
is automatically cleared by Python, provided the modified date on the .py
file is newer.
You could manually delete all .pyc
files in a directory structure with:
find . -name \*.pyc -delete
and Python will re-create them as modules are imported. You can also run:
python -m compileall .
to force a compilation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With