This time I wrote a GUI program of python with Raspberry Pi, and I got stuck when I tried to execute it at startup, so I will summarize the solutions I did at that time.
First of all, this method may not work with the latest Raspbian. I heard that the wind rumors made it impossible ... orz
It says that you can use rc.local, systemctl, cron, etc. to execute the program at startup, but all of them gave an error in the GUI program. Looking at the log, it should have been like I couldn't find DISPLAY ... As a side note, rc.local has been deprecated for some time. If you want to do something at startup, register the service with systemctl.
I used autostart. I found autostart in various places when I looked it up, but this time I confirmed the operation.
/etc/xdg/lxsession/LXDE-pi/autostart
It was only when I messed with the autostart that exists in.
On the last line of autostart,
@lxterminal -e sh /home/pi/python_clock/run.sh
Added.
In /home/pi/python_clock/run.sh
#!/bin/bash cd /home/pi/python_clock python3 clock.py
I wrote that and restarted, and the GUI program written in python worked safely.
It worked fine this time, but autostart is an obsolete method and may not work in the future. If anyone knows another great way, please leave a comment.
Recommended Posts