Anybody have a quick easy way to make a python script automatically run on boot? I've done a little bit of googling and it's not pretty.
Anyone got this going on?
I think that this will work but use the text editor in the GUI or nano in the CLI to make the service file, vi is rather old school.
https://tecadmin.net/setup-autorun-python-script-using-systemd/
Mario
What to pick as a method depends on how you boot your RPI. Do you have it boot into the Desktop? or do you set it to login first? or console automatic login?
Here is a link to 5 ways to do it. run-a-program-on-your-raspberry-pi-at-startup
If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.
Thank you both for the suggestions. I will look at both today and report back.
Well.. even though my script runs just fine once I'm logged in I tried just about every one of those Autostarts and it looks like the sound parts aren't loading on boot. Part of the script has pyaudio sound module and best I can tell at the moment it's not initialized so the card slot isn't available.. at least that's my guess at the moment. I'm going to regroup and give it another try tomorrow probably...
Okay I wanted to report back that this has been solved.
The issue was that one of the sound modules I needed was not capable of running as sudo. each of the various ways to launch an application on boot stops before the user logs in.. so in the end I found this which worked since I needed a terminal anyways.
To note, once you do that process all you get is a terminal window you can stop the application but you don't get desktop or regular command prompt until you undo these things as well.
https://blog.startingelectronics.com/auto-start-a-desktop-application-on-the-rapberry-pi/