Django hashbang行中的Python交互式解释器
对于我的django项目,我想为Django hashbang行中的Python交互式解释器,django,bpython,Django,Bpython,对于我的django项目,我想为manage.py shell编写一个简单的替代品,以利用bpython。基本上,它只需运行setup\u environ(settings),然后导入一些常见的模型(用户等) 在任何情况下,当我运行bpython-I bshell.py(我的脚本名为bshell.py)时,一切正常。然后我想我应该聪明点,把hashbang行设置为#/usr/bin/env-bpython-i使它更简单,这在OSX上是有效的,但现在在Ubuntu(10.10)中不起作用 #/us
manage.py shell
编写一个简单的替代品,以利用bpython。基本上,它只需运行setup\u environ(settings)
,然后导入一些常见的模型(用户等)
在任何情况下,当我运行bpython-I bshell.py
(我的脚本名为bshell.py)时,一切正常。然后我想我应该聪明点,把hashbang行设置为#/usr/bin/env-bpython-i
使它更简单,这在OSX上是有效的,但现在在Ubuntu(10.10)中不起作用
#/usr/bin/env python-i也不起作用,但是#/usr/bin/env-bpython
工作正常(但显然不会进入交互式提示)
这是一个小问题,但在我的一生中,如果我能以/bshell.py
的身份运行脚本,它将为我节省数百个“bpython-i”(我真的很好奇)。你知道为什么它不能在Ubuntu上运行吗
我应该注意到我在一个virtualenv中,我已经仔细检查了行尾是否为*nix样式。来自:
如果这没什么大不了的,那么最好使用bpython
的实际路径,而不是通过/usr/bin/env
Another portability problem is the interpretation of the command arguments.
Some systems, including Linux, do not split up the arguments; for example,
when running the script with the first line like,
#!/usr/bin/env python -c
That is, python -c will be passed as one argument to /usr/bin/env,
rather than two arguments.