Reputation: 23
Python code:
"<stdin>"
#!/usr/bin/env
print "Hello world!"
print "How are you?"
The above is some code that I applied onto a script and it works when run in TextWrangler, but when I put it in Terminal, it fails.
Why is this happening? Does it have to do with the way I open the file?
Upvotes: 1
Views: 7279
Reputation: 103884
The line that starts with #!
is called the shebang line in Unix. By definition, two things are wrong with your shebang:
#!/usr/bin/Python
OR an argument to env to execute the configured Python -- something like #!/usr/bin/env Python
note the argument 'Python' to the utility envUpvotes: 1
Reputation: 184200
/usr/bin/env
is not the correct path to Python. Most likely the shebang line should read:
#!/usr/bin/env python
I am pretty sure it needs to be the first line, so delete the "<stdin>"
line as well (that's ignored by Python anyway).
Also make sure you have set the execute permission on the script: chmod +x /path/to/script.py
Upvotes: 3