不能传递参数与&QUOT到Python;#!的/ usr /斌/包膜蟒蛇" [英] Cannot pass an argument to python with "#!/usr/bin/env python"

查看:121
本文介绍了不能传递参数与&QUOT到Python;#!的/ usr /斌/包膜蟒蛇"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有一个直接执行的python脚本,所以我就开始用#文件!在/ usr /斌/包膜蟒蛇。不过,我也需要缓冲的输出,所以我尝试#在/ usr /斌/包膜蟒蛇-u ,但失败蟒蛇-u!没有这样的文件或目录

I needed to have a directly executable python script, so i started the file with #!/usr/bin/env python. However, I also need unbuffered output, so i tried #!/usr/bin/env python -u, but that fails with python -u: no such file or directory.

我发现#的/ usr / bin中/ Python的-u 的作品,但我需要它来获得蟒蛇 PATH 来支持虚拟 ENV 环境。

I found out that #/usr/bin/python -u works, but I need it to get the python in PATH to support virtual env environments.

我有哪些选择?

推荐答案

这是更好地利用环境变量来启用它。见蟒蛇DOC: http://docs.python.org/2/using/cmdline.html

It is better to use environment variable to enable this. See python doc : http://docs.python.org/2/using/cmdline.html

对于你的情况:

export PYTHONUNBUFFERED=1
script.py

这篇关于不能传递参数与&QUOT到Python;#!的/ usr /斌/包膜蟒蛇"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆