Reputation: 35
I created a python script on my PC (Windows 10) with Python 3.6.2 and it works like a charm :
for i in range(101):
time.sleep(0.015)
print('Starting ..... [%d%%]\r'%i, end="")
else :
print('\n Ready.')
I recently got a raspberry pi running on raspbian with Python 3.4.2 and when I try to run the exact same script from the command I got an error:
print('Starting ..... [%d%%]\r'%i, end="")
^
Syntax Error: invalid Syntax (The error seems to be the equal sign)
Any idea? Maybe Python version? Maybe something else?
EDIT :
Indeed, @Steven Rumbalski is right. Raspbian automaticaly install 2 versions of Python : 2.7.9 and 3.4.2 So I just had to put "python3 myscript.py" instead of "python myscript.py" (or, as @Toandd said : use a shebang line) thank you very much for the help.
Upvotes: 0
Views: 3519
Reputation: 320
I have same idea with @Steven Rumbalski. And to resolve this issue, you should add following line at the top of python script (shebang line).
#!/usr/bin/python3
Or you can run "python3 script.py" if you don't want to add shebang line.
Upvotes: 1