fishbigger / TapoP100

A module for controlling the TP-Link Tapo P100 Plugs
MIT License
566 stars 138 forks source link

Installation problems on raspberry pi #105

Open pho2Github opened 1 year ago

pho2Github commented 1 year ago

TapoP100 works fine on my windows PC using spyder. Installing the package on my raspberry TapoP100 was only successful using "pip3" / "python3". Trying to use TapoP100 then leads to the following error message:

Traceback (most recent call last):
  File "TPLink_P115_Auslesen.py", line 8, in <module>
    from PyP100 import PyP110
  File "/home/pi/.local/lib/python3.5/site-packages/PyP100/PyP110.py", line 12
    URL = f"http:\\{self.ipAddress}\app?token={self.token}"
                                                          ^
SyntaxError: invalid syntax

I also tried to see what happens if I could fix this error (without realy fixing it). I then run into the next error:

Traceback (most recent call last):
  File "TPLink_P115_Auslesen.py", line 8, in <module>
    from PyP100 import PyP110
  File "/home/pi/.local/lib/python3.5/site-packages/PyP100/PyP110.py", line 1, in <module>
    from PyP100 import PyP100
  File "/home/pi/.local/lib/python3.5/site-packages/PyP100/PyP100.py", line 79
    decode: bytes = b64decode(key.encode("UTF-8"))
          ^
SyntaxError: invalid syntax

Any hind how to resolve this?

Belvenix commented 1 year ago

The problem lays in the python version. In the library you can see that the author is using f-string which are introduced in python 3.6 and on stack trace you see rpi uses python 3.5. So you have a couple of alternatives - either fork the repo and change from f"http:\\{self.ipAddress}\app?token={self.token}" string into "http:\\{}\app?token={}".format(self.ipAddress, self.token) and in other places as well if you can only use 3.5 or upgrade python version or just copy the request calls to your own python and work from there.