开发者

Is it possible to stop Django from creating .pyc files, whilst in development?

Is it possible to stop Django from creating the .pyc files? I know it's Python that creates them when modules are imported, but is there some way of turning them off?

Totally understand why they're created, etc, and will want them when I go live, but currently they just clutter up the directory and it bothers me - so please, no "you开发者_StackOverflow社区 shouldn't want to turn them off". I also know how I could stop them appearing, etc, etc. I really just want to know how I can stop them being created.

Oh and I'm on Linux, of course.

Thanks.


You can use this, where applicable:

import sys

sys.dont_write_bytecode = True


You can try setting the PYTHONDONTWRITEBYTECODE environment variable:

  • Python Command line and environment

PYTHONDONTWRITEBYTECODE

If this is set, Python won’t try to write .pyc or .pyo files on the import of source modules.

New in version 2.6.


Very late reply but I got here after Googling. You can try this:

python -B manage.py [any other commands/options]

For example:

python -B manage.py sql yourapp

However, this doesn't work for some reason:

python -B manage.py runserver 0.0.0.0:5000


Edit your dispatcher, so the hashbang reads:

#!/usr/bin/env python -B

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜