python - Can't run crontab without excecuting the programm once -


i wrote script.py should open tkinter window on raspberry:

from tkinter import * import turtle import math import time import sys import os  root = tk() root.config(cursor="none") ccanvas = canvas(root, width = 800, height = 480) root.overrideredirect(1)  turtle_screen = turtle.turtlescreen(ccanvas) ccanvas.pack() turtle = turtle.rawturtle(turtle_screen) turtle.hideturtle() mainloop() 

i able run script command line with:

python /home/pi/script.py 

when tried run via crontab first display not found. fixed with:

display=:0 python /home/pi/script.py 

but following error: _tkinter.tclerror: couldn't connect display ":0" until execute script.py once manual in cmd. crontab able execute script.py without error. how can fix that?

finally solved problem. fine, using root crontab. root crontab not able find display, before display not mentioned/used command. transferred cronjobs "normal" crontab , works fine. point commands, need display (for example tkinter) not work if start them @reboot. have implement sleep time (~30 seconds) in script, display has time become available.

import time  time.sleep(30)  ... 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -