Це відео не доступне.
Перепрошуємо.

How to Autorun/Autostart Your Python Script in the Raspberry Pi OS

Поділитися
Вставка
  • Опубліковано 19 сер 2024
  • In this video I'll show a simple and effective method to autorun or autostart your python script. We will create a .desktop file in the home/pi/.config/autostart folder, with the following minimum lines:
    [Desktop Entry]
    Exec= python3 /home/pi/Desktop/guiautorun.py
    Make sure to change the path in the Exec line to the location for your own python script.
    Good luck! If you found this information helpful, please like the video and subscribe to the channel for more valuable content:)
    Follow me on Twitter: @BaldGuyDIY
    Send me an email: brandon@baldguydiy.com

КОМЕНТАРІ • 334

  • @jasonbills5347
    @jasonbills5347 3 роки тому +8

    Phew, I tried like 5 different youtube vids before I found this one that actually works. Thanks!

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +2

      Glad it could help! Thanks for watching.

  • @JohnDoe-vs9fm
    @JohnDoe-vs9fm Рік тому +1

    FINALLY a working method ! I've tried all the other "easy" ways but none did work as well as this one. From a balding guy to another, thanks man!!

  • @lpxharry1269
    @lpxharry1269 4 місяці тому +1

    Literally a life saver. Thanks for showing the hidden files thing was going crazy trying to find .config

  • @SuperSamaku
    @SuperSamaku 3 роки тому +7

    OHH MY GOD
    I was looking for 3 days to an autostart solution.
    YOU ARE MY HERO RIGHT NOW!!!

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      I’m so glad it was helpful:) Thanks for watching!

  • @jayaramkasi
    @jayaramkasi 3 роки тому +8

    Omg spent so much time trying to make this work!
    You’re a life saver dude

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +1

      That’s exactly how I felt! Thanks for watching.

  • @marksockett4993
    @marksockett4993 8 місяців тому +1

    life saver! spent far to long working on this. worked first time. thank you.

  • @Wyatt-Barton
    @Wyatt-Barton Рік тому +2

    This made my life so much easier than I thought it would be to get this to work! You the man now dawg!

  • @cliveandrew3213
    @cliveandrew3213 3 роки тому +9

    Thank you so much for that, I have been trying loads of stuff for ages, and yours finally works.

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +2

      I’m glad it could help! Thanks for watching.

  • @petervishton
    @petervishton Рік тому +1

    It works! So very many other answers in this category did not. Thank you!

  • @dylanmarcuswalsh
    @dylanmarcuswalsh 3 місяці тому

    I dont think you realize how much this helped me, stopped me from spending another 2 Hours smashing my head into a wall, tysm

  • @Alarm451
    @Alarm451 3 роки тому +2

    Thank you so so much, so many other videos don't make it clear that their methods don't work for desktop apps! This is exactly what I needed!

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +2

      Thanks for watching. So glad it worked for you!

  • @damianhockey8890
    @damianhockey8890 Рік тому +1

    Honestly dude. Thank you so much for this. I'm currently working on a project that requires servos to boot up automatically and VLC playlist to start at the same moment. This has been a huge help. Subbed

    • @BaldGuyDIY
      @BaldGuyDIY  Рік тому

      Glad it was helpful. Good luck on your project!

  • @jayantbarthwal4470
    @jayantbarthwal4470 2 роки тому +13

    Thank you so much for this tutorial, I never thought it would be this easy to do.

  • @fabioESER
    @fabioESER 3 роки тому +3

    At last, something that really works. After hours of testing different forms, this gets the job done.
    Thank you very much for sharing it with us. Greetings from Portugal!

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +3

      Glad it could help. Thanks for watching, and it’s amazing to think my little channel found someone in Portugal!

  • @Penzen11
    @Penzen11 2 роки тому +1

    THANK YOU VERY MUCH! I must have been searching for exactly this answer since forever and three days.

  • @finbenton
    @finbenton 3 місяці тому

    Thanks, this is the only tutorial I found working, only thing I had to add was put "sudo" before python3 in Exec line because my application needed that to run.

  • @TheRedstonelabz1
    @TheRedstonelabz1 2 роки тому +4

    Absolute lifesaver 😅 i have tried all those methods in your list. Thanks mate!

  • @martincook2908
    @martincook2908 2 роки тому +4

    Fantastic, spent hours trying to get it to work, and you made it so easy.. just subscribed

  • @chawesspe3
    @chawesspe3 5 місяців тому

    I know I am late for the party, I'm just glad to show up. After investing hours in trying to make a stupid LED flash at startup, your video solved my problem. How did the world function before online videos?
    Thank you BaldGuyDIY, Charles

  • @AAI30
    @AAI30 3 роки тому

    After trying so many tutorials, one which even bricked my pi and I lost all my stuff,fortunately had a backup, this one actually worked. Thank you

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +1

      So glad it helped! Thanks for watching.

  • @EmmanuelChanda-rd3od
    @EmmanuelChanda-rd3od Рік тому

    As of 2023, definitely wealth the time.Worked for me 💯👌🏽 and I he said for scripts that need to run on the rasp pi desktop.

  • @johnykast1
    @johnykast1 2 роки тому +2

    Perfect! Thanks a lot BaldGuyDIY!!! This is actually the only possible way to make my FEH slideshow to run on startup.
    Great job!!

  • @nelsonaleon
    @nelsonaleon 2 роки тому +1

    You are right, this is the only method that work for GUI.
    Thanks a lot

  • @YashodSachintha
    @YashodSachintha 3 роки тому +1

    Totally wanted 4 days to find this video. Thanks man. Works with shell scripts also. ❤️

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +1

      Glad it was helpful! Thanks for watching.

  • @CreativeBrainsOrganization
    @CreativeBrainsOrganization 3 роки тому +1

    I thought I was just wasteing time watching this tutorial but this actually worked!!!!! Thankyou for spending your time for making this video😁😁

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +1

      Thank you for watching! Glad it was not time wasted:)

    • @CreativeBrainsOrganization
      @CreativeBrainsOrganization 3 роки тому

      @@BaldGuyDIY I wish I got this more earlier

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +1

      @@CreativeBrainsOrganization That’s why I made the video! I thought if it took me several hours to find the answer, maybe I could save a few others some time. Turns out it was a LOT of others:)

    • @CreativeBrainsOrganization
      @CreativeBrainsOrganization 3 роки тому

      @@BaldGuyDIY you are such an awesome guy. Expecting more from your side😁😁

  • @iftihossain6649
    @iftihossain6649 2 роки тому +2

    Thank you for going through all the steps!

  • @juniornewtons8066
    @juniornewtons8066 3 роки тому +1

    Works for me tested with tkinter python file. You are the best.

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +1

      Glad it was helpful. Thanks for watching!

  • @Mcfrantzfrantz
    @Mcfrantzfrantz 7 місяців тому

    Worked great - First time. Very simple and easy to follow. GREAT job!

  • @aleisastia
    @aleisastia 10 місяців тому

    i would give you 100000000000000000000000 likes if i could!! when everything else failed THIS WORKED!!!!!!

  • @carlosgil4343
    @carlosgil4343 3 роки тому

    GREAT!! If you want to run in console, change: Exec=lxterminal -e "python3 /home/pi/Desktop/guiautorun.py" ALSO WORKS!!!!!!!
    Thank you

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      Thanks for watching and for the comment. I’m sure that’s helpful for some people:)

    • @briangkehoe
      @briangkehoe Рік тому

      Thanks for the info, adding Terminal=true did not work for me but your method above using lxterminal works perfectly and now I can get my script running in a terminal on startup so I can monitor the script output

    • @sadiaafrin4498
      @sadiaafrin4498 4 місяці тому

      Thanks a lot!!!!!!

  • @hasielmoreno7166
    @hasielmoreno7166 2 роки тому

    I’ve been looking for this for WEEEEEEEKS
    My man you’re awesome! Thanks for sharing your findings!

  • @adityadadgal5595
    @adityadadgal5595 2 роки тому

    Thank you bro because of your vdo my final year project got successfully done 🙏🙏🙏👍🏻

  • @brassj67
    @brassj67 2 роки тому +1

    Thanks for this. This is the only method I got to work properly!

  • @user-fz8vk1fz8x
    @user-fz8vk1fz8x 2 місяці тому

    감사합니다. 당신의 영상 덕분에 제 문제를 해결할 수 있었습니다. 한국에서 :)
    Thank you for your video. I can solve my problem in Korea :)

  • @yevgenytnc
    @yevgenytnc 3 роки тому

    Thanks for the very helpful video @BalGuyDIY
    Those having issues: try ensuring you have no spaces in either the file path or the file itself

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      Thanks for watching and sharing good advice!

  • @m_aenu
    @m_aenu Рік тому

    OMG Thank you. Finally it works!

  • @r0adk1ll88
    @r0adk1ll88 10 місяців тому

    Great Video. Thank you so much for saving me tons of heartache

  • @TechiReel
    @TechiReel 2 роки тому +1

    fuck man you saved my one more day from running ... doing rnd whole day tried everything and finally this method work ... thanks man

  • @mohammadsamer4541
    @mohammadsamer4541 3 роки тому

    Thank you for this great tutorial !!
    As you mentioned all the other methods were not perfectly running especially for the graphical desktop OS
    When I tried your method it started only one time perfectly at startup but then it did not
    So I found that the problem is the path of the python script that it should be at
    /home/pi/GUI_SCRIPT.py
    not at
    /home/pi/Desktop/GUI_SCRIPT.py
    and this solved the problem in my case then the script is now autostarting every time I boot up my Raspberry Pi :D
    Thanks again for your amazing tutorials :)

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +1

      Thanks for watching and commenting! It just depends on where you’ve saved your script what the path should be. Mine was saved to the desktop, so that’s why it worked for me. If yours was saved to the Pi folder, that explains the need for the oath to be edited. Thanks for watching!

    • @okrimtech
      @okrimtech 3 роки тому

      @@BaldGuyDIY Hey! First of all, thank you so much for this tutorial, it worked for me too. However, I had the same problem as Mohammad. No matter where I put my scrip and how I described the path, it would only work if I dumped my script into the /home/pi folder. Strange. Anyways, thank you once again! :)

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      @@okrimtech I’m glad it worked, and that’s good feedback. I usually start scripts that are on the desktop so I haven’t played with other folders.

  • @ShreyasTambo
    @ShreyasTambo 10 місяців тому

    love you man couldnt find gui startup anywhere else

  • @RichPendlebury
    @RichPendlebury 3 роки тому

    Just like you eluded to at the start of the video. I have been searching high and low for an answer! This worked perfectly. I need a total of 8 .py files to open at once!

    • @RichPendlebury
      @RichPendlebury 3 роки тому

      Although I’ve hit a few snags. The .py files I’m loading are GUI’s created in QtDesigner .. when I use this method none of the assets load with it. (I have images in a sort of slideshow format that display with a button click) any thoughts on why they don’t load?

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      @@RichPendlebury I haven’t created anything in QT Designer, only PySimpleGUI. Does it work without the auto run?

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      Thanks for watching! Glad it could be helpful. It was such a relief when I found it myself.

    • @RichPendlebury
      @RichPendlebury 3 роки тому

      @@BaldGuyDIY normally I have to run it through the terminal which works properly. When I use your method .. it opens but just doesn’t load the images I need to display

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +1

      What if you run it in the desktop environment from Thonny? If it runs correctly there, it should run fine from the auto run. The only other thing I can think of if that’s the case is that it might take time for something to be initialized on boot before it would work. In that case, build a little sleep delay into the start of the scripts and it should work fine. And if one script needs to be running before the others, sleep delay would work well. Or use one script to import the others in the order you need them and call them at the right time.

  • @tambechristian
    @tambechristian 2 роки тому

    Thank you! It works on the new raspios bullseye os, which is a bit different than previous ones.

  • @thomasstriegel8072
    @thomasstriegel8072 3 роки тому

    Thank you sooo much! I was looking for months, to find a solution like this. And it turns out one more time: The most genius things are simple! (You just have to know "how" ;-)). Vielen Dank!!

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      Glad it was helpful! Thanks for watching.

  • @rcbuildmaster6192
    @rcbuildmaster6192 11 місяців тому

    finally got running my server script thanks man

  • @WarDen77
    @WarDen77 2 роки тому

    You are my hero today!!!

    • @BaldGuyDIY
      @BaldGuyDIY  2 роки тому

      Glad it was helpful. Thanks for watching!

  • @kevinwright7931
    @kevinwright7931 2 роки тому

    Thank you very much, It works!! I have tried other ways to a gui to start on boot up. I made a gui for the ir blaster so I can use it with the Raspberry Pi touch screen.

  • @cristiancandia3538
    @cristiancandia3538 3 роки тому

    Muchas gracias! Entre tanto buscar tu explicación me salvó la vida 😃

  • @bitshift264
    @bitshift264 2 роки тому

    Thanks my friend. Finally got it worked!

  • @thegalacticelite
    @thegalacticelite 3 роки тому +1

    Thank you! Thank you! Thank you! I was on the verge of giving up.

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      Glad it was helpful. Thanks for watching!

  • @programmerarnab9046
    @programmerarnab9046 3 роки тому

    I was searching for this video and i looked around 30 videos to find exactly this video from this particular creator :P...

  • @bennyintheshed7821
    @bennyintheshed7821 3 роки тому +2

    It verks! It's verking!! Thanks very much for this, saved me a heap of time :-)

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      So glad it helped. Thanks for watching!

  • @julesw4240
    @julesw4240 3 роки тому

    You just saved me ! This is the only method that worked for me !

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      I’m glad it worked. Thanks for watching!

  • @joaomcs
    @joaomcs Рік тому

    Thank you from Portugal for sharing your script 🍓

  • @ZeeOut9
    @ZeeOut9 3 роки тому

    It works for Raspberry Pi 4
    Thank you!

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      It does! I’ve used it myself now too. Thanks for watching and commenting.

  • @ricardomartinezramos796
    @ricardomartinezramos796 2 роки тому +1

    You are awesome. Thank you for you video and your time.

  • @shreyas441
    @shreyas441 Місяць тому

    thank you boss you saved my time!

  • @vanowarna
    @vanowarna 2 роки тому +1

    This is really useful. Thank you very much !

  • @kevinzywicki6920
    @kevinzywicki6920 2 роки тому +1

    You are an angel sir

  • @krstech1269
    @krstech1269 Рік тому

    Finally it works, thank you

  • @mahdokhtshahshaei6013
    @mahdokhtshahshaei6013 Рік тому

    It works!!! you are a life saver :))

  • @MIDO_0707
    @MIDO_0707 3 роки тому

    Thank you very very very much .
    It worked 100% ...

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      Awesome! Thanks for watching:)

  • @phamhung5062
    @phamhung5062 11 місяців тому

    thanks sir, your video very useful

  • @antonviorel
    @antonviorel 2 роки тому

    It really worked! Thanks!

  • @endrekocsis5686
    @endrekocsis5686 Рік тому

    huh, finally! - thank you, this helped a lot!!!

  • @eilufoye
    @eilufoye 3 роки тому

    Thank you! your videos are the best .

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      Thanks for watching and the kind words!

  • @claudioquinones5107
    @claudioquinones5107 3 роки тому

    Thanks Guy , perfect!!!! autorun file is working OK!

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      Claudio Quiñones Glad it could help. Thanks for watching!

  • @asdasdasasdasdas9073
    @asdasdasasdasdas9073 3 роки тому

    i love you for this tutorial, thanks!

  • @refereeweb5304
    @refereeweb5304 3 роки тому

    That was a lifesaver video...

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      Glad it was! Thanks for watching.

    • @refereeweb5304
      @refereeweb5304 3 роки тому

      @@BaldGuyDIY yeah... trying the same thing on a raspberry 4 right now.. but seems nothing is happening..

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      @@refereeweb5304 Try adding Terminal=True to the .desktop file and see if you get any output in the terminal window that would help diagnose the problem.

  • @lebhafterLebkuchen
    @lebhafterLebkuchen 3 роки тому

    it finally works out! thanks a lot! :)

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +1

      Glad it worked. Thanks for watching!

  • @-d-3370
    @-d-3370 2 роки тому +1

    i wonder why it doesnt work for me, it works just fine before, i changed my sdcard and tried to do this again but i doesnt work anymore. when i reboot my raspberry i guess it does run because the relay is on but it doesnt show the window that supposed to be shown when i run the program. do you know what did i do wrong?

  • @mlungisindlela6810
    @mlungisindlela6810 2 роки тому

    Thanks man. Im gonna use this.

  • @AnandhuAK
    @AnandhuAK 2 роки тому +1

    thanks bro, my problem solved...

  • @muralidharcc655
    @muralidharcc655 3 роки тому

    very very very helpful information. thank you

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +1

      You’re welcome! Thanks for watching, good luck on your projects.

  • @ganda673
    @ganda673 3 роки тому

    Thank you so much for this I can finally start my script at sartup.

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому

      Nice! Thanks for watching:)

  • @kivircikteknoloji
    @kivircikteknoloji Рік тому

    thank u very much, it worked

  • @nabukodosonorogi9025
    @nabukodosonorogi9025 7 місяців тому

    thank you so much man sooooo much

  • @1984maduwantha
    @1984maduwantha 4 роки тому

    very helpful. thank you lot. saving the my time

    • @BaldGuyDIY
      @BaldGuyDIY  4 роки тому

      Glad it could help. Thank you for watching!

  • @fabimawn
    @fabimawn 2 роки тому

    Fantastic!

  • @ElectroniXforu
    @ElectroniXforu 3 роки тому

    Thanks, finally problem resolved

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +1

      Glad it worked! Thanks for watching.

  • @VishalPatel1327
    @VishalPatel1327 2 роки тому

    awsome Time saving tutorial

  • @shrapster43
    @shrapster43 Рік тому

    thank y7ou thank you, you are my hero

  • @siddharthareddy2006
    @siddharthareddy2006 2 роки тому

    Thank you for the solution❤️❤️

  • @ehraz786
    @ehraz786 20 днів тому

    Won't work on non gui versions as .config folder is unavailable

  • @mszivatz
    @mszivatz 2 роки тому

    Thank you! It works :-)

  • @MyChico2012
    @MyChico2012 3 роки тому +1

    thanks bald guy \o/

  • @manish6743
    @manish6743 3 роки тому +2

    Thank you so much for the video. Can we interrupt the python program while it's being executed, like say in case of an infinite loop?

  • @ericgorder1
    @ericgorder1 Рік тому

    Thanks alot!

  • @gazouz6035
    @gazouz6035 2 роки тому

    Thank you very much

  • @MikeSimon
    @MikeSimon 7 місяців тому

    Thank You!!!

  • @corna1906
    @corna1906 3 роки тому

    You are the best

  • @wolfbergi
    @wolfbergi 6 місяців тому

    Hello, it only works to a limited extent. I have a Python Modbus script that listens on port 502. When I start the script automatically like this I get the error message that the port is already in use. I've already tried everything possible. But the error only occurs with the autostart function. maybe an idea? Would be grateful!

  • @pedroc.guerrero8253
    @pedroc.guerrero8253 3 роки тому

    Life-savior!! 🥃

  • @ownownjutt7446
    @ownownjutt7446 3 роки тому +1

    realy use ful

  • @DontMansion
    @DontMansion 2 роки тому

    My script starting automatically after booting but close after 1 minute. In IDLE it works without closing

  • @DT-gm2zi
    @DT-gm2zi 2 роки тому +1

    Hi BaldGuyDIY, I found this video after some searching. I got a script to auto start during boot but it self exits after 1 to 2 second. The program works fine when started manually. I did try adding a delay when it begins but I believe that the boot sequence is killing the thread. Now sure why.

    • @BaldGuyDIY
      @BaldGuyDIY  2 роки тому +1

      What does the script do? What modules need to be imported? Without a lot more detail it’s pretty difficult to know the cause. Likely a runtime error, but without knowing which one it’s hard to know how to proceed.

    • @DT-gm2zi
      @DT-gm2zi 2 роки тому +1

      @@BaldGuyDIY Thanks for your reply. The GUI displays serial data from a com port, however its made to run without an arduino plugged in. Only imports are tkinter and serial. I can see serial data updates for a second or two then exit.

    • @BaldGuyDIY
      @BaldGuyDIY  2 роки тому +1

      @@DT-gm2zi I use PySimpleGUI, which is based on Tkinter. On some Pi’s I need to add 10-20 seconds of delay to the start of the script before it will load consistently at boot.

    • @DT-gm2zi
      @DT-gm2zi 2 роки тому +1

      @@BaldGuyDIY I may have found the solution. I created a .sh file that calls the .py file. It runs instantly and did not close. The only noteworthy thing is all directories have to be fully path defined. Thanks so much BGDIY. Hope this helps others.

  • @evilleppy4330
    @evilleppy4330 Рік тому

    can i do the same thing but make it run a game on start up essentially making the pi into a designated game of whatever one chooses?

  • @expertonnn
    @expertonnn Рік тому

    thanks a lot😁

  • @philipm1896
    @philipm1896 3 роки тому

    Works like a charm 😉

    • @BaldGuyDIY
      @BaldGuyDIY  3 роки тому +1

      Glad it could help! Thanks for watching.

  • @surajm.h
    @surajm.h Рік тому

    Hey actually mine is object detection based project which uses tensor flow but I tried the same method,it didn't work for me in this method , so what else command should I have to use for tensor flow based object detection python code to help it do auto start

  • @selmadjebli5163
    @selmadjebli5163 2 роки тому

    Amazing thanks so much ....but how can i run multiple file in the same time ?????