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



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2008/05/usrbinpython-bad-interpreter-permission/

You should be redirected in 2 seconds.



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

1 comment:

Skawaii said...

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.

About

This is my *OLD* blog. I've copied all of my posts and comments over to my NEW blog at:

http://www.saltycrane.com/blog/.

Please go there for my updated posts. I will leave this blog up for a short time, but eventually plan to delete it. Thanks for reading.