Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a python script '' with

#!/usr/bin/env python

in the first line. When I run in the terminal, I get command not found

I am in the correct directory, and I also have chmod'ed it to be executable. Why won't this run? I am running Ubuntu 10.10 in vmware player.

Edit: Also, when I run /usr/bin/env python from the command line, the python interpreter starts up. So it is in the right place.

Edit edit: I figured it out. Apparently I don't know how to use chmod.

share|improve this question
up vote 2 down vote accepted
python /path/to/monty/


cd /path/to/monty

To execute it the second way (./) the file must be marked as executable:

chmod +x /path/to/monty/
share|improve this answer
It runs when I use python I just don't want to type "python" every time. Also ./ doesn't work, see my comment above. – Java man Apr 13 '11 at 17:35
See my edit about chmod +x – Andrew Lambert Apr 13 '11 at 17:37
Did that before I asked the question. – Java man Apr 13 '11 at 17:39
Try issuing this command: which python and verify that the output matches the path you specified in (/usr/bin/env python) – Andrew Lambert Apr 13 '11 at 17:46
which python gives me /usr/bin/python. I tried changing the first line in the file, still no dice. – Java man Apr 13 '11 at 17:48

Did you create in a windows text editor? If so, try dos2unix

If the file has <cr><nl> endings, then the system will see #!/usr/bin/env python\r and "python\r" can't be found.

share|improve this answer
Written in gedit on ubuntu. – Java man Apr 13 '11 at 18:24
@Java, just to check, what does head -1 | od -c show you as the line ending? – glenn jackman Apr 13 '11 at 18:41
#!/usr/bin/python\n – Java man Apr 13 '11 at 19:18
@Java, please update the question with the current state. I understand that ./ gives "permission denied" and gives "command not found". Is that right? You might want to show us an ls -l listing of the file. – glenn jackman Apr 13 '11 at 19:33

Unless . (the current directory) is in your path, you won't search in the current directory for the file you're running EVEN THOUGH it's in your current directory. Instead, try running ./

share|improve this answer
Stupid comment formatting. ./ bash: ./ Permission denied sudo ./ sudo: / command not found – Java man Apr 13 '11 at 17:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.