1

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

Milliways
62.8k33 gold badges114 silver badges228 bronze badges
asked Dec 18, 2022 at 15:19
1
  • /home/pi/desktop usually has a capital D ie /home/pi/Desktop Commented Dec 21, 2022 at 13:56

2 Answers 2

1

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.

enter image description here

answered Dec 21, 2022 at 13:55
0

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
answered May 22, 2023 at 19:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.