Це відео не доступне.
Перепрошуємо.
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
Phew, I tried like 5 different youtube vids before I found this one that actually works. Thanks!
Glad it could help! Thanks for watching.
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!!
Literally a life saver. Thanks for showing the hidden files thing was going crazy trying to find .config
OHH MY GOD
I was looking for 3 days to an autostart solution.
YOU ARE MY HERO RIGHT NOW!!!
I’m so glad it was helpful:) Thanks for watching!
Omg spent so much time trying to make this work!
You’re a life saver dude
That’s exactly how I felt! Thanks for watching.
life saver! spent far to long working on this. worked first time. thank you.
This made my life so much easier than I thought it would be to get this to work! You the man now dawg!
Thank you so much for that, I have been trying loads of stuff for ages, and yours finally works.
I’m glad it could help! Thanks for watching.
It works! So very many other answers in this category did not. Thank you!
I dont think you realize how much this helped me, stopped me from spending another 2 Hours smashing my head into a wall, tysm
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!
Thanks for watching. So glad it worked for you!
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
Glad it was helpful. Good luck on your project!
Thank you so much for this tutorial, I never thought it would be this easy to do.
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!
Glad it could help. Thanks for watching, and it’s amazing to think my little channel found someone in Portugal!
THANK YOU VERY MUCH! I must have been searching for exactly this answer since forever and three days.
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.
Absolute lifesaver 😅 i have tried all those methods in your list. Thanks mate!
Fantastic, spent hours trying to get it to work, and you made it so easy.. just subscribed
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
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
So glad it helped! Thanks for watching.
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.
Perfect! Thanks a lot BaldGuyDIY!!! This is actually the only possible way to make my FEH slideshow to run on startup.
Great job!!
You are right, this is the only method that work for GUI.
Thanks a lot
Totally wanted 4 days to find this video. Thanks man. Works with shell scripts also. ❤️
Glad it was helpful! Thanks for watching.
I thought I was just wasteing time watching this tutorial but this actually worked!!!!! Thankyou for spending your time for making this video😁😁
Thank you for watching! Glad it was not time wasted:)
@@BaldGuyDIY I wish I got this more earlier
@@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:)
@@BaldGuyDIY you are such an awesome guy. Expecting more from your side😁😁
Thank you for going through all the steps!
Works for me tested with tkinter python file. You are the best.
Glad it was helpful. Thanks for watching!
Worked great - First time. Very simple and easy to follow. GREAT job!
i would give you 100000000000000000000000 likes if i could!! when everything else failed THIS WORKED!!!!!!
GREAT!! If you want to run in console, change: Exec=lxterminal -e "python3 /home/pi/Desktop/guiautorun.py" ALSO WORKS!!!!!!!
Thank you
Thanks for watching and for the comment. I’m sure that’s helpful for some people:)
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
Thanks a lot!!!!!!
I’ve been looking for this for WEEEEEEEKS
My man you’re awesome! Thanks for sharing your findings!
Thank you bro because of your vdo my final year project got successfully done 🙏🙏🙏👍🏻
Thanks for this. This is the only method I got to work properly!
감사합니다. 당신의 영상 덕분에 제 문제를 해결할 수 있었습니다. 한국에서 :)
Thank you for your video. I can solve my problem in Korea :)
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
Thanks for watching and sharing good advice!
OMG Thank you. Finally it works!
Great Video. Thank you so much for saving me tons of heartache
fuck man you saved my one more day from running ... doing rnd whole day tried everything and finally this method work ... thanks man
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 :)
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!
@@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! :)
@@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.
love you man couldnt find gui startup anywhere else
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!
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?
@@RichPendlebury I haven’t created anything in QT Designer, only PySimpleGUI. Does it work without the auto run?
Thanks for watching! Glad it could be helpful. It was such a relief when I found it myself.
@@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
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.
Thank you! It works on the new raspios bullseye os, which is a bit different than previous ones.
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!!
Glad it was helpful! Thanks for watching.
finally got running my server script thanks man
You are my hero today!!!
Glad it was helpful. Thanks for watching!
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.
Muchas gracias! Entre tanto buscar tu explicación me salvó la vida 😃
Thank you for watching!
Thanks my friend. Finally got it worked!
Thank you! Thank you! Thank you! I was on the verge of giving up.
Glad it was helpful. Thanks for watching!
I was searching for this video and i looked around 30 videos to find exactly this video from this particular creator :P...
Thanks for watching, glad it was helpful!
@@BaldGuyDIY sure it was
It verks! It's verking!! Thanks very much for this, saved me a heap of time :-)
So glad it helped. Thanks for watching!
You just saved me ! This is the only method that worked for me !
I’m glad it worked. Thanks for watching!
Thank you from Portugal for sharing your script 🍓
It works for Raspberry Pi 4
Thank you!
It does! I’ve used it myself now too. Thanks for watching and commenting.
You are awesome. Thank you for you video and your time.
thank you boss you saved my time!
This is really useful. Thank you very much !
You are an angel sir
Finally it works, thank you
It works!!! you are a life saver :))
Thank you very very very much .
It worked 100% ...
Awesome! Thanks for watching:)
thanks sir, your video very useful
It really worked! Thanks!
huh, finally! - thank you, this helped a lot!!!
Thank you! your videos are the best .
Thanks for watching and the kind words!
Thanks Guy , perfect!!!! autorun file is working OK!
Claudio Quiñones Glad it could help. Thanks for watching!
i love you for this tutorial, thanks!
Thanks for watching!
That was a lifesaver video...
Glad it was! Thanks for watching.
@@BaldGuyDIY yeah... trying the same thing on a raspberry 4 right now.. but seems nothing is happening..
@@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.
it finally works out! thanks a lot! :)
Glad it worked. Thanks for watching!
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?
Thanks man. Im gonna use this.
thanks bro, my problem solved...
very very very helpful information. thank you
You’re welcome! Thanks for watching, good luck on your projects.
Thank you so much for this I can finally start my script at sartup.
Nice! Thanks for watching:)
thank u very much, it worked
thank you so much man sooooo much
very helpful. thank you lot. saving the my time
Glad it could help. Thank you for watching!
Fantastic!
Thanks, finally problem resolved
Glad it worked! Thanks for watching.
awsome Time saving tutorial
thank y7ou thank you, you are my hero
Thank you for the solution❤️❤️
Thanks for watching!
Won't work on non gui versions as .config folder is unavailable
Thank you! It works :-)
thanks bald guy \o/
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?
Thanks alot!
Thank you very much
Thank You!!!
You are the best
Glad it was helpful!
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!
Life-savior!! 🥃
Glad it was helpful!
realy use ful
My script starting automatically after booting but close after 1 minute. In IDLE it works without closing
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.
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.
@@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.
@@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.
@@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.
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?
thanks a lot😁
Works like a charm 😉
Glad it could help! Thanks for watching.
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
Amazing thanks so much ....but how can i run multiple file in the same time ?????