Aug-21-2018, 07:29 PM
Quote:rob@linux038:~/Desktop$ sudo chmod +x scriptIf this worked then it appears you have two copies of script in your desktop. one called script and one called script.py. It doesnt matter whether there is an extension or not, but if you got a prompt and not an error when you ran this, then it did make it executable and you should be able to now do
rob@linux038:~/Desktop$
~/Desktop$ sudo ./script
(Aug-21-2018, 03:31 PM)Vysero Wrote: I have also tried just running the script with python interpreter like: python script.py (py3 interpreter) and I think it ran but I am not sure.im pretty sure that ubuntu 16.04 defaults python to python2.x and python3 to python3.x. The same is true there. If you get a prompt after running anything, the program ran and is done without error.
Your shebang line (1st comment line) is important when you run a script as an executable in linux. When you put
python3 script.py
you are running the script under python3 (or whatever it is mapped to). When you run it as an executable, you are telling it to run under what is in the shebang line. This could cause confusion as you might be thinking it is running under py2, when you are really using py2. This is assuming you have not changed the default though or symlinked it elsewhere.
Recommended Tutorials: