in a file called test.py I have the following code
#!/usr/bin/python3
with open('test.txt','w') as File:
print(1,file=File)
When I do
$ python3 test.py
It runs fine. But when I do
$ chmod +x test.py
$ ./test.py
I get a SyntaxError:
File "./test.py", line 4
print(1,file=File)
^
SyntaxError: invalid syntax
Any one has any idea why? Thank you
I'm running Python 3.3.1 in Ubuntu 13.04
which python3tell you is the path?/usr/bin/python3is not what you think it is.which pythonis/usr/bin/python3which is python 3.3.1 (if I run/usr/bin/python3I get the Python 3.3.1 interpreter. More so, If I do/usr/bin/python3 test.pyit all works nice)import sys; print(sys.executable)? Edit: might also be worth addingprint(sys.version).