[SOLVED] Permission issue when running Python script with ExecuteCommandLine

Hi,

I am running OpenHab on a RPi3+ with the standard Openhabian setup.

I tried setting up python script to execute on a cron task every minute to fetch data from a 3rd party API (Sense Energy Monitor).

For some reason, the script errors out when run as the openhab user but works like a charm when run with openhabian. Here is the output I get when running it as openhab :

sudo -u openhab python sense_data.py
Traceback (most recent call last):
File “sense_data.py”, line 5, in
openhab = openhab.OpenHAB(base_url)
AttributeError: ‘module’ object has no attribute ‘OpenHAB’

I am using the python-openhab library to import the results into Openhab and this works fine with Openhabian. Any ideas which files/directories need permissions adjusted ?

Did you install libraries using pip? Did you use sudo to install those libraries? If not they only got installed for the openhabian user.

Do you have more than one file that makes up your script? If so then you may need to cd to that folder before running the script from openHAB because the other files that make up your program will not be in the running directory.

1 Like

Thanks @rlkoshak.

I had not used sudo for both libraries (sense_energy and python-openhab). I reinstalled python-openhab with sudo and it works now !

1 Like