Search code examples
pythonexecutablepermission-deniedshebang

Python shebang execution permission denied


I have a very simple script called blah.py which looks like this:

#!/space/jazz/1/users/gwarner/anaconda/bin python
print 'here'

My which python returns /space/jazz/1/users/gwarner/anaconda/bin/python and ls -l blah.py returns -rwxrwxr-x 1 gwarner gwarner 64 Jul 13 14:16 blah.py. My username is gwarner. However, when I try to execute this script from the directory it lives in using ./blah.py I get ./blah.py: Permission denied. It runs correctly when I execute it using python blah.py. What is going on?


Solution

  • I think you have an extra space in the shebang line... try this:

    #!/space/jazz/1/users/gwarner/anaconda/bin/python