【发布时间】:2015-11-07 13:31:01
【问题描述】:
我在 django 生产环境中使用 PythonAnyhwere。我有一个应该按计划运行的脚本。
因为我在 virtualenv 中安装了 django,所以脚本开始像
#!/usr/bin/env python
activate_this = '/home/myname/.virtualenvs/myenv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
我得到的错误是
/usr/bin/env python: no such Python interpreter
没问题。所以我把它改成
#!/usr/bin/env python2.7
然后我得到了
/usr/bin/env python2.7: no such Python interpreter
或
/usr/bin/env python3.4: no such Python interpreter
我说好的,如果我根本没有 shebang 线怎么办? 日志错误:
line 1: activate_this: command not found
line 2: syntax error near unexpected token `activate_this,'
line 2: `execfile(activate_this, dict(__file__=activate_this))'
那怎么办呢?
【问题讨论】:
-
你试过
$which python并把输出放到你的shebang吗? -
没有。如何在我的脚本中实现它?
-
如果您可以访问它,只需在终端中执行它。没有
$符号 -
外壳说
/usr/bin/python -
尝试放到shebang中看看有没有帮助
标签: python django pythonanywhere