Python 2 versus 3 and what is Domoticz using

Python and python framework

Moderator: leecollings

Post Reply
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Python 2 versus 3 and what is Domoticz using

Post 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))\
freijn
Posts: 536
Joined: Friday 23 December 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands Purmerend
Contact:

Re: Python 2 versus 3 and what is Domoticz using

Post by freijn »

How do you fire the script?

> python3 SonosSwitchOff.py

vs

>python2.7 SonosSwitchOff.py
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python 2 versus 3 and what is Domoticz using

Post by rgroothuis »

I'm using the following on the command line:

python3 SonosSwitchOff.py

python SonosSwitchOff.py

The last command is executing Python 2.
Post Reply