adafruit / Adafruit_IO_Python

Adafruit IO Python Client Library
Other
223 stars 97 forks source link

Syntax error when import MQTTClient on Raspian 9 with Python 3.5.3 #156

Closed jmangum closed 1 week ago

jmangum commented 3 weeks ago

from Adafruit_IO import MQTTClient Traceback (most recent call last): File "", line 1, in File "/home/pi/.local/lib/python3.5/site-packages/Adafruit_IO/init.py", line 21, in from .client import Client File "/home/pi/.local/lib/python3.5/site-packages/Adafruit_IO/client.py", line 266 res = self._get(f'feeds/{feed}/details') ^ SyntaxError: invalid syntax

tyeth commented 3 weeks ago

Hey @jmangum thanks for reporting this! Your version of python is pretty old, I am not sure the minimum version but in my head it's probably 3.8 or 3.10. Also stretch is pretty old now too. You might want to update for security fixes along with feature and performance improvements, then retest.

jmangum commented 3 weeks ago

Thank you @tyeth . I believe that the instructions say python 3.4+ is required, so I think I am ok with regards python version (unless the README needs to be updated). Upgrading Raspian would require a rebuild, which I was hoping to avoid.

tyeth commented 3 weeks ago

Ah good spot. Yeah the readme probably wants updating, seems support for f-strings is possible but not supported out the box until 3.6 https://stackoverflow.com/questions/38865348/are-f-strings-supposed-to-work-in-python-3-4#46225926

jmangum commented 3 weeks ago

Thank you @tyeth. I should really upgrade both Raspian (to Raspberry Pi OS) and python.

tyeth commented 3 weeks ago

Thank you @tyeth. I should really upgrade both Raspian (to Raspberry Pi OS) and python.

Just be aware that comes with some of its own problems / changes / gotchas, mainly the preferred use of virtual environments or venv's, but the odd thing still needing system level installation.

Adafruit learn guides exist for such things though, and the forums and discord offer good company for any encountered problems

jmangum commented 1 week ago

Thank you @tyeth. I ultimately decided to upgrade by to Raspberry Pi OS, which elevated me to python 3.11. Was able to install and (almost) get it working. I think that this issue can be closed (noting the possible update to the README regarding minimum requirements).