Reputation: 387
Well I have this code:
#!/usr/bin/env python3
for i in range(15):
print(i, end=' ')
when I run it like this in command prompt:
prog1.py
I get:
C:\Users\Ja\Desktop>prog1.py
File "C:\Users\Ja\Desktop\prog1.py", line 4
print(i, end=' ')
^
SyntaxError: invalid syntax
but when I run it like this:
py prog1.py
it works fine. It's running python2.7.15 instead of python3.6.5 (I tested it using sys.version). ( It's the same for icon clicks )
Upvotes: 1
Views: 203
Reputation: 249283
You may be under the impression that Windows understands the "shebang line":
#!/usr/bin/env python3
It does not. All Windows knows is that .py files can be run by Python. So you need to update your file association, or run the correct version of Python explicitly, passing the path to your script as an argument.
Upvotes: 1