시작 시 Python 스크립트를 실행할 수 없습니다. 라즈베리 파이 4

시작 시 Python 스크립트를 실행할 수 없습니다. 라즈베리 파이 4

부팅할 때 Raspberry pi 4에서 Python 스크립트를 실행하려고 합니다. 이 Python 스크립트를 직접 실행하면 오류 없이 작동합니다. 다음과 같이 crontab 파일을 편집했습니다.

# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
@reboot python /home/pi/FUZEGUI.py > /home/pi/FUZEGUIlog.txt

로그 파일에 정보가 없습니다. 나는 다른 접근 방식을 시도했습니다 rc.local.

# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi
printf "Launching FUZE GUI"
sudo python home/pi/FUZEGUI.py &
exit 0

하지만 그것도 작동하지 않습니다. 스크립트

#!/usr/bin/env python
try:
    import Tkinter as tk
except:
    import tkinter as tk
from PIL import Image, ImageTk
import time
import threading

root = tk.Tk()
root.attributes('-fullscreen', True)
root.geometry("800x800")

# Define Canvas
canvas = tk.Canvas(root, width=800, height=800)
canvas.grid(row=0, column=0)


# translates an rgb tuple of int to a tkinter friendly color code
def _from_rgb(rgb):
    return "#%02x%02x%02x" % rgb


# Called when user presses View Log button
def viewLogRaise():
    # Hide Previous Windows
    canvas.itemconfigure(logButtonWindow, state="hidden")
    canvas.itemconfigure(titleLabelWindow, state="hidden")
    # Open Closed Windows
    canvas.itemconfigure(backButtonWindow, state="normal")
    canvas.itemconfigure(logTextWindow, state="normal")
    canvas.itemconfigure(scrollbarWindow, state="normal")
    #I want to read the file continuously at this point.
    t =threading.Thread(target=readFile)
    t.start()

def backToMenu():
    # Hide Previous Windows
    canvas.itemconfigure(backButtonWindow, state="hidden")
    canvas.itemconfigure(logTextWindow, state="hidden")
    canvas.itemconfigure(scrollbarWindow, state="hidden")
    # Open Closed Windows
    canvas.itemconfigure(logButtonWindow, state="normal")
    canvas.itemconfigure(titleLabelWindow, state="normal")


def follow(thefile,reading):
    count= 0
    thefile.seek(0, 2)
    count += 1
    while reading == True:
        line = thefile.readline()
        if not line:
            time.sleep(0.1)
            continue
        yield line
def readFile():
    logfile = open("fast.log", "r")
    loglines = follow(logfile,True)
    for line in loglines:
        logText.insert(tk.END, line)
    


# Background
pathToGif = "redpoly4.jpg"
# red_background=Image.open("redBackground.gif")
backgroundImage = ImageTk.PhotoImage(file=pathToGif)
canvas.background = backgroundImage
bg = canvas.create_image(0, 0, anchor=tk.NW, image=backgroundImage)
titleLabel = tk.Label(root, fg="white", text="FUZE", borderwidth=2, relief="solid", bg=_from_rgb((239, 36, 37)),
                      font=("Courier", 100))
titleLabelWindow = canvas.create_window(400, 120, window=titleLabel)
logButton = tk.Button(root, fg="white", text="View Log", command=viewLogRaise, borderwidth=2, relief="raised",
                      bg=_from_rgb((239, 36, 37)), font=("Courier", 46))
logButtonWindow = canvas.create_window(400, 320, window=logButton)
backButton = tk.Button(root, fg="white", text="Back", command=backToMenu, borderwidth=2, relief="raised",
                       bg=_from_rgb((239, 36, 37)), font=("Courier", 20))
backButtonWindow = canvas.create_window(70, 360, window=backButton)



canvas.itemconfigure(backButtonWindow, state="hidden")
logText = tk.Text(root, bg="white", height=22, width=60, borderwidth=2, relief="solid")
logTextWindow = canvas.create_window(450, 208, window=logText)
# attach text widget to scrollbar
scrollbar = tk.Scrollbar(root)
scrollbar.grid(row=1,column=3)
scrollbarWindow = canvas.create_window(710,200, window=scrollbar)
logText.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=logText.yview)
canvas.itemconfigure(scrollbarWindow,state="hidden")
canvas.itemconfigure(logTextWindow, state="hidden")
root.mainloop()

관련 정보