How to create a Linux executable file using python code - Stack Overflow
allow it to be executed. To do it, you must use the chmod
command as follows:
chmod +x youfile.py
.
The +x
add the right to be executed.
Ubuntu doesn't know that he must use the python
command to run it. To resolve this, we use the sha-bang line (for more information, see the wikipedia page): at the first line of your script, you must write #! program_to_use
, in your case it's python.
Generally, we take benefit of the env
variables, and use #! /usr/bin/env python
, but you can also choose yourself the version of python you want, doing
#! /usr/bin/pythonX.X
where X.X is the version of python.