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

1
  • /home/pi/desktop usually has a capital D ie /home/pi/Desktop
    – CoderMike
    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

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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.