Page 1 of 1

Python 2 versus 3 and what is Domoticz using

Posted: Friday 25 September 2020 10:48
by rgroothuis
I've a Python script using soco lib to control Sonos. On the command line the script is working fine with Python 3 but not with Python 2. Something is not supported in Python 2 (error statement at the bottom of this post).

When Domtoicz is running the script I get the error meessage:

Code: Select all

2020-09-25 10:35:22.544 Error: Error executing script command (/home/pi/domoticz/scripts/python/SonosSwitchOff.py). returned: 256
I believe this is due to the fact this error message is returned when using Python 2.

If this is the case, how can I force Domoticz to use Python 3 when executing this script?
Any suggestions on how to fix this?

Soco Python 2 error message:

Code: Select all

SonosSwitchOff.py:4: UserWarning: Version 0.19 of SoCo is the last to support Python 2.7
  import soco
/home/pi/.local/lib/python2.7/site-packages/soco/services.py:693: FutureWarning: The behavior of this method will change in future versions.  Use specific 'len(elem)' or 'elem is not None' test instead.
  value_list_elt = state.find('{}allowedValueList'.format(ns))\

Re: Python 2 versus 3 and what is Domoticz using

Posted: Friday 25 September 2020 11:11
by freijn
How do you fire the script?

> python3 SonosSwitchOff.py

vs

>python2.7 SonosSwitchOff.py

Re: Python 2 versus 3 and what is Domoticz using

Posted: Friday 25 September 2020 11:37
by rgroothuis
I'm using the following on the command line:

python3 SonosSwitchOff.py

python SonosSwitchOff.py

The last command is executing Python 2.