attwad/python-osc

Running with root possible?

janfiess opened this issue · 3 comments

I need to run python-osc together with the rpi_ws281x module (Adafruit library for running addressable LED pixels).
For running that library I need root
However, if I use root with python-osc, the module will not be found. Is there any solution.
I found similar issues, but the did not work for me.

dvzrv commented

How (and as which user) did you install python-osc on the host?
If you did not install it system-wide (e.g. to /usr/lib/python3.9/site-packages/ - the location may be different on your distribution!) root will not be able to access the module.

Ah this helped! Thanks man! I installed it again with sudo pip3 install, then it appeared!

dvzrv commented

@janfiess do note, that using sudo pip is never a good idea though.

It will install to the system-wide location, but it will also lead to this (language package manager based) installation conflicting with any system package provided files (when on Debian this might not be the case as they heavily patch pip to work different from the upstream suggestions, ie. by installing to /usr/local/lib/python3.9/). This will lead to conflicts and broken setups on nearly all Linux distributions.

The ideal way is to either rely on a system package management provided package (if available), or to fix the setup you are using to allow running the code as an unprivileged user (from a security perspective the latter is always preferable).

Looking at the documentation of the rpi_ws281x package it states clearly:

SPI requires you to be in the gpio group if you wish to control your LEDs without root.

You do not need root to run your code, but you need to add your user to the gpio group (I assume this applies to Debian). If in doubt check the ownership on the device node that you want to communicate with.