I have a python script with a GUI that was designed with qt5, the script runs fine whenever I run it through the terminal or Thonny IDE. But no matter how much I tried, after trying many guides, videos, Chatgpt sessions I couldn't make it run on boot or AutoStart after boot to the Raspbian..

After I gave up I built a distributable file using pyinstaller --onefile your_script.py and tried the same but with no success!.

Now at the end I am satisfied of having my application running by double clicking it's icon from the desktop which is as well not working as:

  • the exe file should be in the same folder of the python scripts and other files.
  • every time I double click it, it asks "Execute, execute in terminal, cancel".

Is there a way to just create a desktop shortcut to run the application directly?

3 Answers 3


A search for Raspberry Pi desktop autostart app had https://forums.raspberrypi.com/viewtopic.php?t=294014 as the first hit. It describes 4 ways to do what you want, depending on your OS and other factors.

One method requires using the command line. Assuming you are user pi:

mkdir -p /home/pi/.config/lxsession/LXDE-pi
cp /etc/xdg/lxsession/LXDE-pi/autostart /home/pi/.config/lxsession/LXDE-pi/

Edit the file /home/pi/.config/lxsession/LXDE-pi/autostart and add a new line at the bottom, naming your process. The reference show this example, to start a Python 3 script:

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@lxterminal -e python3 /path/my_script.py

For Debian 12.4 Bookworm on RPi4 only the "Traditional" methods of that mentioned link How to Use Autostart for Desktop worked for me.

I created a .desktop file and it executed in both the /etc/xdg/autostart and alternately a created /home/pi/.config/autostart/ directories.

  • Seeing this question was asked BEFORE Bookworm this does not answer the question
    – Milliways
    Dec 26, 2023 at 2:42

I've used crontab with varying success,

a guide here by another user using it with GPIO pins and python is below.

crontab guide

It should be the same for GUI based scripts.

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.