I am trying to run a python script in linux without calling python explicitly.
My goal is to have $ myscript.py
run my script. Currently calling $ python myscript.py
works but I am looking to not have to type the extra command for ease of use. I added the shebang line to the first line of my script to get the proper python call. I have tried both of the following lines and neither has worked for me.
#!/usr/bin/env python2.7
#!/usr/local/bin/python2.7
The problem is that I get the following behavior
$ python2.7 myscript.py # This will run
$ myscript.py # This is the error
$ ./myscript.py # This will also error
: Permission denied # Error message
When I do ls -ltr
on the file I have executable permission for the script and the executable
-rwxrwxr-x 1 uname users 3544 Jul 7 08:46 myscript.py
-rwxr-xr-x 1 root root 6231413 Jul 7 00:57 /usr/local/bin/python2.7
I can also call python in the command line by typing what is written in either the shebang lines into it.
/usr/bin/env python2.7
/usr/local/bin/python2.7
both run python in the terminal.
I have ran through the following stackoverflow problems and none seem to answer why this problem is happening to me.