On Terminal,
>> which python
/Users/Chois/.pyenv/shims/python
aa.py
# !/Users/Chois/.pyenv/shims python
print("a")
On Terminal,
chmod 755 aa.py
And execute it,
./aa.py
It occured errors
./aa.py: line 3: syntax error near unexpected token `"a"'
./aa.py: line 3: `print("a")'
What's wrong with it?
asked Mar 26, 2018 at 3:07
user3595632
5,78011 gold badges61 silver badges129 bronze badges
2 Answers 2
Rather than using full path for the python binary, your shebang line could use the env instruction. Then, your shebang line will end up being something like this:
#!/usr/bin/env python
Sign up to request clarification or add additional context in comments.
Comments
The shebang line is blatantly wrong... You shouldn't have a space between the hash and the bang:
#!/Users/Chois/.pyenv/shims/python
There's also a missing slash that I filled it for you.
answered Mar 26, 2018 at 3:10
iBug
37.6k8 gold badges101 silver badges155 bronze badges
Comments
lang-py
/betweenshimsandpythonin the hashbang (having a space instead), and have an erroneous space between#and!