SOLVED - Error running script from remote press

I am attempting to run a script by pressing a button on my remote but I get an error message when I try.

CPythonInvoker(8): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.

The script, which disables and enables HDMI, works from the command line, and worked when activated the same way in Raspbmc

Here is the script:

import subprocess
import string
result = subprocess.check_output(“cat ~/screen.state”, shell=True)
if (result.find (“f”) >0 ):
subprocess.call( “vcgencmd display_power 1”, shell=True )
subprocess.call( “echo ‘On’ > /home/osmc/screen.state” , shell=True )
else:
subprocess.call( “vcgencmd display_power 0”, shell=True )
subprocess.call( “echo ‘Off’ > /home/osmc/screen.state”, shell=True )

and it is called from remote.xml with

<power>RunScript(/home/osmc/scripts/power.py)</power>

Edit. Running latest update on Raspberry pi 2

This message is only a warning and is not your problem. The same warning appears when our Settings addon calls an external python script to install updates.

Silly question, but do you have

#!/usr/bin/python

At the start of your power.py script ? Otherwise the shell won’t know to invoke python as you are not including /usr/bin/python in your Runscript call.

I tried adding that line but it made no difference. I assume python is being called as the line before the warning message above is;

–>Python Interpreter Initialized<-

The script worked as shown in Raspbmc and works from the command line.

Try using full paths in your script
change “vcgencmd display_power…” to “/opt/vc/bin/vcgencmd display_power…”
and so on

Thanks @Dilligaf, that solved it perfectly.

In theory with Shell=True full paths shouldn’t have been necessary as it’s running within a shell that should pull in the default path. But it is a good idea to always use full paths in circumstances like this.