[英]mod_python ignoring shebang and using Python 2 instead of 3
I'm trying to run a script in the browser. 我正在尝试在浏览器中运行脚本。 I installed
mod_python
for running web-based applications on the server and set a shebang in my script: 我安装了
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()
However, when I run my script from the browser ( my application ), I see that the Python version is 2. When I run the script from the console, using: 但是,当我从浏览器( 应用程序 )运行脚本时,我看到Python版本是2。当从控制台运行脚本时,使用:
python3 index.py
Python version 3.3.5 is used as expected. 预期使用Python版本3.3.5。 Why is
mod_python
ignoring the shebang? 为什么
mod_python
忽略了shebang?
UPD. UPD。 The Question closed
问题结案
Set executable flag on the file: 在文件上设置可执行标志:
chmod a+x yourfile.py
Then, execute it as: 然后,将其执行为:
./yourfile.py
When shebang is used follow this steps to run the code. 使用shebang时,请按照以下步骤运行代码。
This makes your file executable 这使您的文件可执行
chmod +x index.py
This helps your code to execute 这有助于您的代码执行
./index.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.