Saltycrane logo

SaltyCrane Blog

Notes on Python, Django, and web development on Ubuntu Linux

    

/usr/bin/python: bad interpreter: Permission denied error

I have a Python script, myscript.py with a #!/usr/bin/python shebang* at the top and tried to execute it on Ubuntu Linux using ./myscript.py. I got the following error message:
 
bash:  ./myscript.py: /usr/bin/python: bad interpreter: Permission  denied
 
Here are things to check:
  • The file should be executable (use chmod +x myscript.py)
  • The file shoud have Unix line endings
  • The file shouldn't be on a fat32 or ntfs filesystem. Apparently, bash can't handle scripts that are stored on fat32 or ntfs
* #!/usr/bin/env python would be the more portable shebang

2 Comments — feed icon Comments feed for this post


#1 Skawaii commented on 2008-05-20:

I had the same problem when transfer a python script that I had started in Windows to my Macbook. Good old dos2unix to the rescue, and presto! It worked.


#2 Eliot commented on 2008-10-20:

Skawaii, I haven't used dos2unix myself, but glad to hear that it worked well for you.

Post a comment

Required
Required, but not displayed
Optional

Format using Markdown. (No HTML.)
  • Code blocks: prefix each line by at least 4 spaces or 1 tab (and a blank line before and after)
  • Code span: surround with backticks
  • Blockquotes: prefix lines to be quoted with >
  • Links: <URL>
  • Links w/ description: [description](URL)
Created with Django | Hosted by Slicehost