Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7503

Advanced users • Re: How to make a Python Script that requires Superuser run at boot

$
0
0
(someone has to say it)
While the above would work, I suspect this is another case of sudo-ism. Sudo is not requiered to light a Neopixel strip. Or is there something else in your script that requieres sudo, and does it really requiere it?
In most cases it boils down on using virtual environments. Once you have the hang of them it's easy, but they can be terrifying in the beginning.
1. Create and activate the virtual environment
2. pip install dependencies (make sure again that the environment is activated)
3. test with "python program.py" from within the virtual environment (again, make sure it's activated)
4. test again, but this time use <full path to the venv>/bin/python program.py
5. deactivate the virtual environment, and do step 4 again

Once all this works, you can skip steps 4 and 5 for future projects, but keep in mind that that is the line you need to run your program from cron, systemd or whatever.

Statistics: Posted by kheylen25 — Fri Feb 21, 2025 1:32 pm



Viewing all articles
Browse latest Browse all 7503

Trending Articles