简体   繁体   中英

Stop python from generating pyc files

When I change my Python code, I often need to delete the associated pyc file, or Python will not regenerate it and will run the old code. Is there a way to tell Python not to generated pyc files?

When you import a file, Python will first look at the corresponding .py file, and if it's newer than the .pyc file, it'll be recompiled.

I'd advise you to check that your system (and its clock) is acting sanely, so the .py files you modify get a new modified timestamp.

See the docs: http://docs.python.org/tutorial/modules.html#compiled-python-files

Edit the .bashrc file and add the following lines to the very end of the file:

PYTHONDONTWRITEBYTECODE=True
export PYTHONDONTWRITEBYTECODE

Restart your terminal or do the following:

$ source ~/.bashrc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM