[英]mod_python ignoring shebang and using Python 2 instead of 3
我正在嘗試在瀏覽器中運行腳本。 我安裝了mod_python
以便在服務器上運行基於Web的應用程序,並在腳本中設置了一個shebang:
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import sys
def index():
print ("Content-type: text/html\n")
print('Version Python {0}'.format(sys.version_info[0]))
if __name__ == '__main__':
index()
但是,當我從瀏覽器( 應用程序 )運行腳本時,我看到Python版本是2。當從控制台運行腳本時,使用:
python3 index.py
預期使用Python版本3.3.5。 為什么mod_python
忽略了shebang?
UPD。 問題結案
在文件上設置可執行標志:
chmod a+x yourfile.py
然后,將其執行為:
./yourfile.py
使用shebang時,請按照以下步驟運行代碼。
這使您的文件可執行
chmod +x index.py
這有助於您的代碼執行
./index.py
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.