2015-11-07 99 views
1

我使用PythonAnyhwere作爲我的django製作環境。我有一個應該按計劃運行的腳本。Shebang for scripts does not working

由於我是在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 

我說好吧,如果我沒有什麼家當行呢? 錯誤日誌:

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))' 

什麼是那麼的方式嗎?

+0

你有沒有試過'$哪個python'並把輸出放到你的shebang? – valignatev

+0

不可以。我如何在腳本中實現它? – Saphire

+0

只需在終端中執行它即可訪問它。沒有'$'標記 – valignatev

回答

1

可以知道通過鍵入

$ which python 

Python解釋你也嘗試這樣的事情(或者沒有env):

$ env python 
Python 3.5.0 (default, Sep 20 2015, 11:28:25) 
[GCC 5.2.0] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import os 
>>> os.path 
<module 'posixpath' from '/usr/lib/python3.5/posixpath.py'> 

,然後更改libbin和省略/posixpath.py部分