Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't run script #18

Closed
msslava opened this issue Jun 6, 2020 · 8 comments
Closed

Doesn't run script #18

msslava opened this issue Jun 6, 2020 · 8 comments

Comments

@msslava
Copy link

msslava commented Jun 6, 2020

Hi,

The last update does not run the script.

~/xiaomi_mi_scale/src $ python3 Xiaomi_Scale.py File "Xiaomi_Scale.py", line 146 sys.stdout.write(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Publishing data to topic {MQTT_PREFIX + '/' + user + '/weight'}: {message}\n") ^ SyntaxError: invalid syntax

My environment:
raspberry pi 2
bluetooth stick

@bpaulin
Copy link
Contributor

bpaulin commented Jun 6, 2020

Hello,

Syntax error may come from a wrong python version, can you send python --version ?

@msslava
Copy link
Author

msslava commented Jun 19, 2020

Hello,
Sorry for the late reply,
I have Python 2.7.13 installed

@lolouk44
Copy link
Owner

you need python3 to run the script.
if you run the script manually, make sure you call it with python3 (like you did above):
Try and run it un-buffered (with -u):
python3 -u Xiaomi_Scale.py

@msslava
Copy link
Author

msslava commented Jun 19, 2020

Same error:

pi@server:~/xiaomi_mi_scale/src $ python3 -u Xiaomi_Scale.py File "Xiaomi_Scale.py", line 146 sys.stdout.write(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Publishing data to topic {MQTT_PREFIX + '/' + user + '/weight'}: {message}\n") ^ SyntaxError: invalid syntax

@lolouk44
Copy link
Owner

lolouk44 commented Jun 19, 2020

which version of python3 do you have?
(python3 --version)
The only thing I can think of is the f-strings which need python 3.6 or higher
Any reason you're not using the docker container? All pre-requisites are installed for you...

@msslava
Copy link
Author

msslava commented Jun 19, 2020

Python 3.5.3.

I do not use docker, because the raspberry does not have enough performance. The containers stop after a while.
All pre-requisites are installed.

@lolouk44
Copy link
Owner

ok, then you need to upgrade to python 3.6 or higher...
Alternatively feel free to update the sys.stdout.write lines that include f-strings (starting f") and replace them with the "old" style as you see fit...

@msslava
Copy link
Author

msslava commented Jun 19, 2020

Ok, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants