Raspberry Pi uses systemd to automatically run a program when the Pi boots. I'm getting an error about, "no display name and no $DISPLAY environment variable". However, it works fine when run from a shell prompt.
Feb 16 14:39:16 raspberrypi systemd[1]: Started py-kms.
Feb 16 14:39:17 raspberrypi python3[13828]: Traceback (most recent call last):
Feb 16 14:39:17 raspberrypi python3[13828]: File "pykms_Server.py", line 512, in <module>
Feb 16 14:39:17 raspberrypi python3[13828]: server_main_no_terminal()
Feb 16 14:39:17 raspberrypi python3[13828]: File "pykms_Server.py", line 445, in server_main_no_terminal
Feb 16 14:39:17 raspberrypi python3[13828]: server_with_gui()
Feb 16 14:39:17 raspberrypi python3[13828]: File "pykms_Server.py", line 429, in server_with_gui
Feb 16 14:39:17 raspberrypi python3[13828]: root = pykms_GuiBase.KmsGui()
Feb 16 14:39:17 raspberrypi python3[13828]: File "/home/pi/py-kms/py-kms/pykms_GuiBase.py", line 69, in __init__
Feb 16 14:39:17 raspberrypi python3[13828]: tk.Tk.__init__(self, *args, **kwargs)
Feb 16 14:39:17 raspberrypi python3[13828]: File "/usr/lib/python3.5/tkinter/__init__.py", line 1880, in __init__
Feb 16 14:39:17 raspberrypi python3[13828]: self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
Feb 16 14:39:17 raspberrypi python3[13828]: _tkinter.TclError: no display name and no $DISPLAY environment variable
Feb 16 14:39:17 raspberrypi python3[13828]: During handling of the above exception, another exception occurred:
Feb 16 14:39:17 raspberrypi python3[13828]: Traceback (most recent call last):
Feb 16 14:39:17 raspberrypi python3[13828]: File "pykms_Server.py", line 514, in <module>
Feb 16 14:39:17 raspberrypi python3[13828]: server_main_terminal()
Feb 16 14:39:17 raspberrypi python3[13828]: File "pykms_Server.py", line 405, in server_main_terminal
Feb 16 14:39:17 raspberrypi python3[13828]: server_check()
Feb 16 14:39:17 raspberrypi python3[13828]: File "pykms_Server.py", line 321, in server_check
Feb 16 14:39:17 raspberrypi python3[13828]: logger_create(loggersrv, srv_config, mode = 'a')
Feb 16 14:39:17 raspberrypi python3[13828]: File "/home/pi/py-kms/py-kms/pykms_Misc.py", line 105, in logger_create
Feb 16 14:39:17 raspberrypi python3[13828]: backupCount = 1, encoding = None, delay = 0))
Feb 16 14:39:17 raspberrypi python3[13828]: File "/usr/lib/python3.5/logging/handlers.py", line 150, in __init__
Feb 16 14:39:17 raspberrypi python3[13828]: BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
Feb 16 14:39:17 raspberrypi python3[13828]: File "/usr/lib/python3.5/logging/handlers.py", line 57, in __init__
Feb 16 14:39:17 raspberrypi python3[13828]: logging.FileHandler.__init__(self, filename, mode, encoding, delay)
Feb 16 14:39:17 raspberrypi python3[13828]: File "/usr/lib/python3.5/logging/__init__.py", line 1009, in __init__
Feb 16 14:39:17 raspberrypi python3[13828]: StreamHandler.__init__(self, self._open())
Feb 16 14:39:17 raspberrypi python3[13828]: File "/usr/lib/python3.5/logging/__init__.py", line 1038, in _open
Feb 16 14:39:17 raspberrypi python3[13828]: return open(self.baseFilename, self.mode, encoding=self.encoding)
Feb 16 14:39:17 raspberrypi python3[13828]: PermissionError: [Errno 13] Permission denied: '/var/log/pykms_logserver.log'
Feb 16 14:39:17 raspberrypi systemd[1]: py-kms.service: Main process exited, code=exited, status=1/FAILURE
Feb 16 14:39:17 raspberrypi systemd[1]: py-kms.service: Unit entered failed state.
Feb 16 14:39:17 raspberrypi systemd[1]: py-kms.service: Failed with result 'exit-code'.
Feb 16 14:39:18 raspberrypi systemd[1]: py-kms.service: Service hold-off time over, scheduling restart.
Feb 16 14:39:18 raspberrypi systemd[1]: Stopped py-kms.
Feb 16 14:39:18 raspberrypi systemd[1]: Started py-kms.
Feb 16 14:39:19 raspberrypi python3[13836]: Traceback (most recent call last):
Feb 16 14:39:19 raspberrypi python3[13836]: File "pykms_Server.py", line 512, in <module>
Feb 16 14:39:19 raspberrypi python3[13836]: server_main_no_terminal()
Feb 16 14:39:19 raspberrypi python3[13836]: File "pykms_Server.py", line 445, in server_main_no_terminal
Feb 16 14:39:19 raspberrypi python3[13836]: server_with_gui()
Feb 16 14:39:19 raspberrypi python3[13836]: File "pykms_Server.py", line 429, in server_with_gui
Feb 16 14:39:19 raspberrypi python3[13836]: root = pykms_GuiBase.KmsGui()
Feb 16 14:39:19 raspberrypi python3[13836]: File "/home/pi/py-kms/py-kms/pykms_GuiBase.py", line 69, in __init__
Feb 16 14:39:19 raspberrypi python3[13836]: tk.Tk.__init__(self, *args, **kwargs)
Feb 16 14:39:19 raspberrypi python3[13836]: File "/usr/lib/python3.5/tkinter/__init__.py", line 1880, in __init__
Feb 16 14:39:19 raspberrypi python3[13836]: self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
Feb 16 14:39:19 raspberrypi python3[13836]: _tkinter.TclError: no display name and no $DISPLAY environment variable
Feb 16 14:39:19 raspberrypi python3[13836]: During handling of the above exception, another exception occurred:
Feb 16 14:39:19 raspberrypi python3[13836]: Traceback (most recent call last):
Feb 16 14:39:19 raspberrypi python3[13836]: File "pykms_Server.py", line 514, in <module>
Feb 16 14:39:19 raspberrypi python3[13836]: server_main_terminal()
Feb 16 14:39:19 raspberrypi python3[13836]: File "pykms_Server.py", line 405, in server_main_terminal
Feb 16 14:39:19 raspberrypi python3[13836]: server_check()
Feb 16 14:39:19 raspberrypi python3[13836]: File "pykms_Server.py", line 321, in server_check
Feb 16 14:39:19 raspberrypi python3[13836]: logger_create(loggersrv, srv_config, mode = 'a')
Feb 16 14:39:19 raspberrypi python3[13836]: File "/home/pi/py-kms/py-kms/pykms_Misc.py", line 105, in logger_create
Feb 16 14:39:19 raspberrypi python3[13836]: backupCount = 1, encoding = None, delay = 0))
Feb 16 14:39:19 raspberrypi python3[13836]: File "/usr/lib/python3.5/logging/handlers.py", line 150, in __init__
Feb 16 14:39:19 raspberrypi python3[13836]: BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
Feb 16 14:39:19 raspberrypi python3[13836]: File "/usr/lib/python3.5/logging/handlers.py", line 57, in __init__
Feb 16 14:39:19 raspberrypi python3[13836]: logging.FileHandler.__init__(self, filename, mode, encoding, delay)
Feb 16 14:39:19 raspberrypi python3[13836]: File "/usr/lib/python3.5/logging/__init__.py", line 1009, in __init__
Feb 16 14:39:19 raspberrypi python3[13836]: StreamHandler.__init__(self, self._open())
Feb 16 14:39:19 raspberrypi python3[13836]: File "/usr/lib/python3.5/logging/__init__.py", line 1038, in _open
Feb 16 14:39:19 raspberrypi python3[13836]: return open(self.baseFilename, self.mode, encoding=self.encoding)
Feb 16 14:39:19 raspberrypi python3[13836]: PermissionError: [Errno 13] Permission denied: '/var/log/pykms_logserver.log'
Feb 16 14:39:19 raspberrypi systemd[1]: py-kms.service: Main process exited, code=exited, status=1/FAILURE
Feb 16 14:39:19 raspberrypi systemd[1]: py-kms.service: Unit entered failed state.
Feb 16 14:39:19 raspberrypi systemd[1]: py-kms.service: Failed with result 'exit-code'.
Feb 16 14:39:19 raspberrypi systemd[1]: py-kms.service: Service hold-off time over, scheduling restart.
Feb 16 14:39:19 raspberrypi systemd[1]: Stopped py-kms.
Feb 16 14:39:19 raspberrypi systemd[1]: Started py-kms.
Feb 16 14:39:20 raspberrypi python3[13841]: Traceback (most recent call last):
Feb 16 14:39:20 raspberrypi python3[13841]: File "pykms_Server.py", line 512, in <module>
Feb 16 14:39:20 raspberrypi python3[13841]: server_main_no_terminal()
Feb 16 14:39:20 raspberrypi python3[13841]: File "pykms_Server.py", line 445, in server_main_no_terminal
Feb 16 14:39:20 raspberrypi python3[13841]: server_with_gui()
Feb 16 14:39:20 raspberrypi python3[13841]: File "pykms_Server.py", line 429, in server_with_gui
Feb 16 14:39:20 raspberrypi python3[13841]: root = pykms_GuiBase.KmsGui()
Feb 16 14:39:20 raspberrypi python3[13841]: File "/home/pi/py-kms/py-kms/pykms_GuiBase.py", line 69, in __init__
Feb 16 14:39:20 raspberrypi python3[13841]: tk.Tk.__init__(self, *args, **kwargs)
Feb 16 14:39:20 raspberrypi python3[13841]: File "/usr/lib/python3.5/tkinter/__init__.py", line 1880, in __init__
Feb 16 14:39:20 raspberrypi python3[13841]: self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
Feb 16 14:39:20 raspberrypi python3[13841]: _tkinter.TclError: no display name and no $DISPLAY environment variable
Feb 16 14:39:20 raspberrypi python3[13841]: During handling of the above exception, another exception occurred:
Feb 16 14:39:20 raspberrypi python3[13841]: Traceback (most recent call last):
Feb 16 14:39:20 raspberrypi python3[13841]: File "pykms_Server.py", line 514, in <module>
Feb 16 14:39:20 raspberrypi python3[13841]: server_main_terminal()
Feb 16 14:39:20 raspberrypi python3[13841]: File "pykms_Server.py", line 405, in server_main_terminal
Feb 16 14:39:20 raspberrypi python3[13841]: server_check()
Feb 16 14:39:20 raspberrypi python3[13841]: File "pykms_Server.py", line 321, in server_check
Feb 16 14:39:20 raspberrypi python3[13841]: logger_create(loggersrv, srv_config, mode = 'a')
Feb 16 14:39:20 raspberrypi python3[13841]: File "/home/pi/py-kms/py-kms/pykms_Misc.py", line 105, in logger_create
Feb 16 14:39:20 raspberrypi python3[13841]: backupCount = 1, encoding = None, delay = 0))
Feb 16 14:39:20 raspberrypi python3[13841]: File "/usr/lib/python3.5/logging/handlers.py", line 150, in __init__
Feb 16 14:39:20 raspberrypi python3[13841]: BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
Feb 16 14:39:20 raspberrypi python3[13841]: File "/usr/lib/python3.5/logging/handlers.py", line 57, in __init__
Feb 16 14:39:20 raspberrypi python3[13841]: logging.FileHandler.__init__(self, filename, mode, encoding, delay)
Feb 16 14:39:20 raspberrypi python3[13841]: File "/usr/lib/python3.5/logging/__init__.py", line 1009, in __init__
Feb 16 14:39:20 raspberrypi python3[13841]: StreamHandler.__init__(self, self._open())
Feb 16 14:39:20 raspberrypi python3[13841]: File "/usr/lib/python3.5/logging/__init__.py", line 1038, in _open
Feb 16 14:39:20 raspberrypi python3[13841]: return open(self.baseFilename, self.mode, encoding=self.encoding)
Feb 16 14:39:20 raspberrypi python3[13841]: PermissionError: [Errno 13] Permission denied: '/var/log/pykms_logserver.log'
Feb 16 14:39:20 raspberrypi systemd[1]: py-kms.service: Main process exited, code=exited, status=1/FAILURE
Feb 16 14:39:20 raspberrypi systemd[1]: py-kms.service: Unit entered failed state.
Feb 16 14:39:20 raspberrypi systemd[1]: py-kms.service: Failed with result 'exit-code'.
Feb 16 14:39:20 raspberrypi systemd[1]: py-kms.service: Service hold-off time over, scheduling restart.
Feb 16 14:39:20 raspberrypi systemd[1]: Stopped py-kms.
Feb 16 14:39:20 raspberrypi systemd[1]: Started py-kms.
Feb 16 14:39:21 raspberrypi python3[13847]: Traceback (most recent call last):
Feb 16 14:39:21 raspberrypi python3[13847]: File "pykms_Server.py", line 512, in <module>
Feb 16 14:39:21 raspberrypi python3[13847]: server_main_no_terminal()
Feb 16 14:39:21 raspberrypi python3[13847]: File "pykms_Server.py", line 445, in server_main_no_terminal
Feb 16 14:39:21 raspberrypi python3[13847]: server_with_gui()
Feb 16 14:39:21 raspberrypi python3[13847]: File "pykms_Server.py", line 429, in server_with_gui
Feb 16 14:39:21 raspberrypi python3[13847]: root = pykms_GuiBase.KmsGui()
Feb 16 14:39:21 raspberrypi python3[13847]: File "/home/pi/py-kms/py-kms/pykms_GuiBase.py", line 69, in __init__
Feb 16 14:39:21 raspberrypi python3[13847]: tk.Tk.__init__(self, *args, **kwargs)
Feb 16 14:39:21 raspberrypi python3[13847]: File "/usr/lib/python3.5/tkinter/__init__.py", line 1880, in __init__
Feb 16 14:39:21 raspberrypi python3[13847]: self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
Feb 16 14:39:21 raspberrypi python3[13847]: _tkinter.TclError: no display name and no $DISPLAY environment variable
Feb 16 14:39:21 raspberrypi python3[13847]: During handling of the above exception, another exception occurred:
Feb 16 14:39:21 raspberrypi python3[13847]: Traceback (most recent call last):
Feb 16 14:39:21 raspberrypi python3[13847]: File "pykms_Server.py", line 514, in <module>
Feb 16 14:39:21 raspberrypi python3[13847]: server_main_terminal()
Feb 16 14:39:21 raspberrypi python3[13847]: File "pykms_Server.py", line 405, in server_main_terminal
Feb 16 14:39:21 raspberrypi python3[13847]: server_check()
Feb 16 14:39:21 raspberrypi python3[13847]: File "pykms_Server.py", line 321, in server_check
Feb 16 14:39:21 raspberrypi python3[13847]: logger_create(loggersrv, srv_config, mode = 'a')
Feb 16 14:39:21 raspberrypi python3[13847]: File "/home/pi/py-kms/py-kms/pykms_Misc.py", line 105, in logger_create
Feb 16 14:39:21 raspberrypi python3[13847]: backupCount = 1, encoding = None, delay = 0))
Feb 16 14:39:21 raspberrypi python3[13847]: File "/usr/lib/python3.5/logging/handlers.py", line 150, in __init__
Feb 16 14:39:21 raspberrypi python3[13847]: BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
Feb 16 14:39:21 raspberrypi python3[13847]: File "/usr/lib/python3.5/logging/handlers.py", line 57, in __init__
Feb 16 14:39:21 raspberrypi python3[13847]: logging.FileHandler.__init__(self, filename, mode, encoding, delay)
Feb 16 14:39:21 raspberrypi python3[13847]: File "/usr/lib/python3.5/logging/__init__.py", line 1009, in __init__
Feb 16 14:39:21 raspberrypi python3[13847]: StreamHandler.__init__(self, self._open())
Feb 16 14:39:21 raspberrypi python3[13847]: File "/usr/lib/python3.5/logging/__init__.py", line 1038, in _open
Feb 16 14:39:21 raspberrypi python3[13847]: return open(self.baseFilename, self.mode, encoding=self.encoding)
Feb 16 14:39:21 raspberrypi python3[13847]: PermissionError: [Errno 13] Permission denied: '/var/log/pykms_logserver.log'
Feb 16 14:39:21 raspberrypi systemd[1]: py-kms.service: Main process exited, code=exited, status=1/FAILURE
Feb 16 14:39:21 raspberrypi systemd[1]: py-kms.service: Unit entered failed state.
Feb 16 14:39:21 raspberrypi systemd[1]: py-kms.service: Failed with result 'exit-code'.
Feb 16 14:39:21 raspberrypi systemd[1]: py-kms.service: Service hold-off time over, scheduling restart.
Feb 16 14:39:21 raspberrypi systemd[1]: Stopped py-kms.
Feb 16 14:39:21 raspberrypi systemd[1]: Started py-kms.
Feb 16 14:39:22 raspberrypi python3[13852]: Traceback (most recent call last):
Feb 16 14:39:22 raspberrypi python3[13852]: File "pykms_Server.py", line 512, in <module>
Feb 16 14:39:22 raspberrypi python3[13852]: server_main_no_terminal()
Feb 16 14:39:22 raspberrypi python3[13852]: File "pykms_Server.py", line 445, in server_main_no_terminal
Feb 16 14:39:22 raspberrypi python3[13852]: server_with_gui()
Feb 16 14:39:22 raspberrypi python3[13852]: File "pykms_Server.py", line 429, in server_with_gui
Feb 16 14:39:22 raspberrypi python3[13852]: root = pykms_GuiBase.KmsGui()
Feb 16 14:39:22 raspberrypi python3[13852]: File "/home/pi/py-kms/py-kms/pykms_GuiBase.py", line 69, in __init__
Feb 16 14:39:22 raspberrypi python3[13852]: tk.Tk.__init__(self, *args, **kwargs)
Feb 16 14:39:22 raspberrypi python3[13852]: File "/usr/lib/python3.5/tkinter/__init__.py", line 1880, in __init__
Feb 16 14:39:22 raspberrypi python3[13852]: self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
Feb 16 14:39:22 raspberrypi python3[13852]: _tkinter.TclError: no display name and no $DISPLAY environment variable
Feb 16 14:39:22 raspberrypi python3[13852]: During handling of the above exception, another exception occurred:
Feb 16 14:39:22 raspberrypi python3[13852]: Traceback (most recent call last):
Feb 16 14:39:22 raspberrypi python3[13852]: File "pykms_Server.py", line 514, in <module>
Feb 16 14:39:22 raspberrypi python3[13852]: server_main_terminal()
Feb 16 14:39:22 raspberrypi python3[13852]: File "pykms_Server.py", line 405, in server_main_terminal
Feb 16 14:39:22 raspberrypi python3[13852]: server_check()
Feb 16 14:39:22 raspberrypi python3[13852]: File "pykms_Server.py", line 321, in server_check
Feb 16 14:39:22 raspberrypi python3[13852]: logger_create(loggersrv, srv_config, mode = 'a')
Feb 16 14:39:22 raspberrypi python3[13852]: File "/home/pi/py-kms/py-kms/pykms_Misc.py", line 105, in logger_create
Feb 16 14:39:22 raspberrypi python3[13852]: backupCount = 1, encoding = None, delay = 0))
Feb 16 14:39:22 raspberrypi python3[13852]: File "/usr/lib/python3.5/logging/handlers.py", line 150, in __init__
Feb 16 14:39:22 raspberrypi python3[13852]: BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
Feb 16 14:39:22 raspberrypi python3[13852]: File "/usr/lib/python3.5/logging/handlers.py", line 57, in __init__
Feb 16 14:39:22 raspberrypi python3[13852]: logging.FileHandler.__init__(self, filename, mode, encoding, delay)
Feb 16 14:39:22 raspberrypi python3[13852]: File "/usr/lib/python3.5/logging/__init__.py", line 1009, in __init__
Feb 16 14:39:22 raspberrypi python3[13852]: StreamHandler.__init__(self, self._open())
Feb 16 14:39:22 raspberrypi python3[13852]: File "/usr/lib/python3.5/logging/__init__.py", line 1038, in _open
Feb 16 14:39:22 raspberrypi python3[13852]: return open(self.baseFilename, self.mode, encoding=self.encoding)
Feb 16 14:39:22 raspberrypi python3[13852]: PermissionError: [Errno 13] Permission denied: '/var/log/pykms_logserver.log'
Feb 16 14:39:22 raspberrypi systemd[1]: py-kms.service: Main process exited, code=exited, status=1/FAILURE
Feb 16 14:39:22 raspberrypi systemd[1]: py-kms.service: Unit entered failed state.
Feb 16 14:39:22 raspberrypi systemd[1]: py-kms.service: Failed with result 'exit-code'.
Feb 16 14:39:23 raspberrypi systemd[1]: py-kms.service: Service hold-off time over, scheduling restart.
Feb 16 14:39:23 raspberrypi systemd[1]: Stopped py-kms.
Feb 16 14:39:23 raspberrypi systemd[1]: py-kms.service: Start request repeated too quickly.
Feb 16 14:39:23 raspberrypi systemd[1]: Failed to start py-kms.
Feb 16 14:39:23 raspberrypi systemd[1]: py-kms.service: Unit entered failed state.
Feb 16 14:39:23 raspberrypi systemd[1]: py-kms.service: Failed with result 'exit-code'.