python-osc icon indicating copy to clipboard operation
python-osc copied to clipboard

Running with root possible?

Open janfiess opened this issue 3 years ago • 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.

janfiess avatar Aug 11 '21 09:08 janfiess

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.

dvzrv avatar Aug 11 '21 10:08 dvzrv

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

janfiess avatar Aug 12 '21 07:08 janfiess

@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.

dvzrv avatar Aug 13 '21 10:08 dvzrv