Reputation: 666
I'm gett a strange problem when running python script from linux, it doesn't seem to bother running the script file (I've put a print statement on the first line and it doesn't come out):
zl@o-xterm-71 h2bin> python main.py
Python 2.7.3 (default, Feb 4 2013, 18:00:47)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
The script runs fine on my laptop with 2.7.5, and even with 2.4.3 so I'd assume it's not a version problem. Should be something simple that I missed.. Anyone had this before? Thanks!
edit1:
dummy.py:
def main():
print "it works"
if __name__ == '__main__':
main()
output:
zl@o-xterm-71 h2bin> python dummy.py
Python 2.7.3 (default, Feb 4 2013, 18:00:47)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
Typing 'python' gives the exact same thing.
Upvotes: 1
Views: 288
Reputation: 8020
tarvalon:/tmp$ cat dummy.py
def main():
print("it works")
if __name__ == '__main__':
main()
tarvalon:/tmp$ python dummy.py
it works
So, it works. There's some problem with your installation. Looks like your python file is a script that is calling the real python binary without parameters. Best commands to debug that: file which python
, cat which python
and, most important, python --help.
Upvotes: 1
Reputation: 304137
You could explain this behaviour if someone/something put a wrapper script/program named python
in your PATH, that runs a real Python interpreter, but neglects to pass the arguments.
Upvotes: 0
Reputation: 14863
Not 100% sure about this, but I think the quotes are messing things up for you.
Change:
print “it works”
To
print "it works"
Upvotes: 0