title: Permission denied running python script with the shebang line in linux
body: <p>I am trying to run a python script in linux without calling python explicitly.
  My goal is to have <code>$ myscript.py</code> run my script. Currently calling <code>$ python myscript.py</code> 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.</p>
  
  <pre><code>#!/usr/bin/env python2.7
  #!/usr/local/bin/python2.7
  </code></pre>
  
  <p>The problem is that I get the following behavior</p>
  
  <pre><code>$ python2.7 myscript.py    # This will run
  
  $ myscript.py           # This is the error
  $ ./myscript.py         # This will also error
  : Permission denied     # Error message
  </code></pre>
  
  <p>When I do <code>ls -ltr</code> on the file I have executable permission for the script and the executable</p>
  
  <pre><code>-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
  </code></pre>
  
  <p>I can also call python in the command line by typing what is written in either the shebang lines into it.</p>
  
  <pre><code>/usr/bin/env python2.7
  /usr/local/bin/python2.7
  </code></pre>
  
  <p>both run python in the terminal.</p>
  
  <p>I have ran through the following stackoverflow problems and none seem to answer why this problem is happening to me.</p>
  
  <p><a href="https://stackoverflow.com/questions/11060612/bash-permission-denied-for-python">bash permission denied for python</a></p>
  
  <p><a href="https://stackoverflow.com/questions/38491587/python-script-problems-with-shebang-line-unix">Python script: problems with shebang line (unix)</a></p>