I am trying to make a python script executable. The script is an testHelloWorld.py
#!/usr/bin/env python
print 'Hello World'
I have made it executable by running
chmod +x testHelloWorld.py
$ python testHelloWorld.py
prints "Hello World". But $ ./testHelloWorld.py
doesn't do anything.
What am I missing here?
I am using a Mac Os X device and its running Python 2.7.5.
I have gone through the answers for earlier questions and have checked for mistakes, but still no luck. This is one such similar post - how to make python script self-executable
On my mac:
#! /usr/bin/python
print 'Hello world'
Then
chmod +x <filename>.py
and finally
$ ./<filename>.py
gives me...
Hello world
So it is just the first line. Change to #! /usr/bin/python
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With