I have set up a python script, that uses tkinter to launch a window and display some data.
My goal now is to let the Pi run this script after boot. For this, I tried many ways I found on the internet. I tried rc.local, crontab, lxsession, but nothing did the job.
What I've tried so far in case of lxsession: As I could not find the Lxsession configurator in the toolbar menu, I tried to edit the autostart file in
/home/pi/.config/lxsession/LXDE/autostart
Intending to start my program I added
@/home/pi/desktop/script.py
at the bottom of the file, but my script still did not run on boot.
Thanks for help VRK
-
/home/pi/desktop usually has a capital D ie /home/pi/DesktopCoderMike– CoderMike2022年12月21日 13:56:42 +00:00Commented Dec 21, 2022 at 13:56
2 Answers 2
I suggest you start by getting a simple python program running at boot.
Create the following simple code and save as /home/pi/hello.py
import time
print('Hello World')
time.sleep(120)
Add the following to /etc/xdg/lxsession/LXDE-pi/autostart
@lxterminal -e python3 /home/pi/hello.py
This will start the python program in a terminal window so that you can see any output.
I got this somewhere a long time ago and it works into my product flawlessly:
sudo mkdir /home/pi/.config/autostart
then open nano:
sudo nano /home/pi/.config/autostart/yourname.desktop
finally, the content of the file:
[Desktop Entry]
Type=Application
Name=yourname
Exec=/usr/bin/python3 /home/pi/yourfolder/Program.py