Posts: 1
Joined: Sun Aug 04, 2019 10:17 am

Running a Python script with tkinter from boot

Thu Aug 08, 2019 2:23 pm

I'm new to this forum so hope I've put this request in the right place. Please advise me if I haven't!
I have written a program which is running fine in Python3 within the IDE (Thonny). It also runs fine from the command prompt in a terminal window.
However I need to be able to fire this program from bootup without loading the desktop gui.
My script and associated database and picture files are stored in Documents under /home/pi/Documents.
Running the program then from the Documents folder:
pi@Pi-Geoff:~/Documents $ python3 myscript.py
This produces the following error:
Traceback (most recent call last):
File "myscript.py", line 25, in <module>
root = Tk()
File "/usr/lib/python3.7/tkinter/__init__.py", line 2023, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

If anyone can help by pointing me in the right direction I would be most grateful. I have searched the web for solutions but so far nothing that seems to fit my issue.

I am running Raspbian Version 10 (buster) on a very early Pi B Revision 0002

User avatar
Posts: 434
Joined: Mon Dec 15, 2014 7:14 pm
Location: Noo Joysey, USA

Re: Running a Python script with tkinter from boot

Thu Aug 08, 2019 2:57 pm

Return to “Python”