Can't make python files executable in os x
<p>I want to put the path to the python file first in the file to run it without having to type python before it. Here is the output of the terminal that comfiuses me</p>

<pre><code>[Wolfie@Wolfies-MacBook-Pro] [08:54:28] [/Applications/MAMP/cgi-bin]
$python test.py
blaaaaa

[Wolfie@Wolfies-MacBook-Pro] [08:54:32] [/Applications/MAMP/cgi-bin]
$which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

[Wolfie@Wolfies-MacBook-Pro] [08:54:39] [/Applications/MAMP/cgi-bin]
$cat test.py
#!/Library/Frameworks/Python.framework/Versions/2.7/bin/python
print "blaaaaa"

[Wolfie@Wolfies-MacBook-Pro] [08:54:45] [/Applications/MAMP/cgi-bin]
$ls -l test.py
-rwxr-xr-x  1 Wolfie  admin  83 Oct 14 08:53 test.py

[Wolfie@Wolfies-MacBook-Pro] [08:54:49] [/Applications/MAMP/cgi-bin]
$./test.py
: No such file or directoryry/Frameworks/Python.framework/Versions/2.7/bin/python
./test.py: line 2: print: command not found
</code></pre>

<p>On Ubuntu, Debian and Red Hat this way works. I also tried with "/usr/bin/python" and "/usr/local/bin/python3" which work when I put it before the filename in the terminal and run it but not when I put it first in the file then chmod +x it.</p>

<p>With any programming language, I'll use <code>#!/usr/bin/env [language]</code> and in this case replace <code>[language]</code> with <code>python</code>.</p>

python osx