I want to run the Python GUI when starting Raspberry Pi

This time I wrote a GUI program of python with Raspberry Pi, and I got stuck when I tried to execute it at startup, so I will summarize the solutions I did at that time.

At the beginning

First of all, this method may not work with the latest Raspbian. I heard that the wind rumors made it impossible ... orz

environment

Failure plan

It says that you can use rc.local, systemctl, cron, etc. to execute the program at startup, but all of them gave an error in the GUI program. Looking at the log, it should have been like I couldn't find DISPLAY ... As a side note, rc.local has been deprecated for some time. If you want to do something at startup, register the service with systemctl.

solution

I used autostart. I found autostart in various places when I looked it up, but this time I confirmed the operation. /etc/xdg/lxsession/LXDE-pi/autostart It was only when I messed with the autostart that exists in. On the last line of autostart, @lxterminal -e sh /home/pi/python_clock/run.sh Added.

In /home/pi/python_clock/run.sh

#!/bin/bash cd /home/pi/python_clock python3 clock.py

I wrote that and restarted, and the GUI program written in python worked safely.

Summary

It worked fine this time, but autostart is an obsolete method and may not work in the future. If anyone knows another great way, please leave a comment.

Recommended Posts

I want to run the Python GUI when starting Raspberry Pi
I want to be notified of the connection environment when the Raspberry Pi connects to the network
I want to prevent the speaker connected to the Raspberry Pi (jessie) from bouncing when the OS is restarted (Python script)
I want to display the progress in Python!
When I tried to run Python, it was skipped to the Microsoft Store
I connected the thermo sensor to the Raspberry Pi and measured the temperature (Python)
About the error I encountered when trying to use Adafruit_DHT from Python on a Raspberry Pi
[Python] I want to know the variables in the function when an error occurs!
How to use the Raspberry Pi relay module Python
I talked to Raspberry Pi
I want to inherit to the back with python dataclass
I want to write in Python! (3) Utilize the mock
I want to use the R dataset in python
I want to run a quantum computer with Python
I want to do something in Python when I finish
I want to initialize if the value is empty (python)
[Python] I want to use the -h option with argparse
I want to disable interrupts on Raspberry Pi (≒ DI / EI)
Set the fastest python file execution after starting Raspberry Pi.
I want to know the features of Python and pip
Change the message displayed when logging in to Raspberry Pi
I want to be able to run Python in VS Code
I sent the data of Raspberry Pi to GCP (free)
I want to debug with Python
[Raspberry Pi] Changed Python default to Python3
I want to know the weather with LINE bot feat.Heroku + Python
I tried to automate the watering of the planter with Raspberry Pi
[Linux] I want to know the date when the user logged in
I want to output the beginning of the next month with Python
Use python on Raspberry Pi 3 to illuminate the LED (Hello World)
I want to pin Spyder to the taskbar
I want to output to the console coolly
I want to handle the rhyme part1
I want to handle the rhyme part3
I want to use jar from python
I want to build a Python environment
I want to analyze logs with Python
I want to play with aws with python
Run servomotor on Raspberry Pi 3 using python
I tried to estimate the pi stochastically
I want to display the progress bar
I want to handle the rhyme part2
I want to handle the rhyme part5
I want to handle the rhyme part4
Note: I want to do home automation with Home Assistant + Raspberry Pi + sensor # 1
Python Note: When you want to know the attributes of an object
Use python on Raspberry Pi 3 to light the LED with switch control!
(Python Selenium) I want to check the settings of the download destination of WebDriver
[Python] I tried to analyze the pitcher who achieved no hit no run
I want to batch convert the result of "string" .split () in Python
I want to explain the abstract class (ABCmeta) of Python in detail.
I tried to make a traffic light-like with Raspberry Pi 4 (Python edition)
Python: I want to measure the processing time of a function neatly
I want to do Dunnett's test in Python
I want to use MATLAB feval with python
I want to memoize including Python keyword arguments
How to use Raspberry Pi pie camera Python
I want to create a window in Python
I want to email from Gmail using Python.
[Python] I want to manage 7DaysToDie from Discord! 1/3
I want to make a game with Python