开发者

(How To) Check the value of my sys.path by logging the value to a temporary file

So I've had a problem with my PYTHONPATH lately.

I've been told to "check the value of sys.path explicitly at the beginning of the settings.py file and log the value to a temporary file".

In semi-laymans t开发者_高级运维erms, how is this done?

Thanks.


In your settings.py, assuming Python 2.6 or newer:

import sys
with open("somefile.txt") as f:
    f.write(sys.path)

Or you could "print sys.path" if you were using runserver, and see the value in the console output.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜