停止python生成pyc文件
当我更改 Python 代码时,我经常需要删除关联的 pyc 文件,否则 Python 将不会重新生成它并运行旧代码。有没有办法告诉Python不要生成pyc
文件?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑
.bashrc
文件并将以下行添加到文件的最后:重新启动终端或执行以下操作:
Edit the
.bashrc
file and add the following lines to the very end of the file:Restart your terminal or do the following:
当你导入一个文件时,Python会首先查看相应的
.py
文件,如果它比.pyc
文件新,它就会被重新编译。我建议您检查您的系统(及其时钟)是否运行正常,以便您修改的 .py 文件获得新的修改时间戳。
请参阅文档: http://docs.python.org/tutorial/modules .html#compiled-python-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