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:
#!/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:
python3 index.py
Python version 3.3.5 is used as expected. Why is mod_python
ignoring the shebang?
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.
This makes your file executable
chmod +x index.py
This helps your code to execute
./index.py
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.