Issues with ESPHome Dashboard when running as system service

Hi, I have installed ESPHome on raspian Buster (raspberry pi 4) and python 3.7.3 using pip3. Everything works as expected when running it from the command line:

 esphome /home/homeassistant/.homeassistant/esphome dashboard

But when I install it as a systemd service I’m getting this error:

Sep 30 13:35:40 raspi4 esphome[30888]:     handlers[type_](self, json_message)
Sep 30 13:35:40 raspi4 esphome[30888]:   File "/home/pi/.local/lib/python3.7/site-packages/esphome/dashboard/dashboard.py", line 212, in handle_spawn
Sep 30 13:35:40 raspi4 esphome[30888]:     stdin=tornado.process.Subprocess.STREAM)
Sep 30 13:35:40 raspi4 esphome[30888]:   File "/home/pi/.local/lib/python3.7/site-packages/tornado/process.py", line 248, in __init__
Sep 30 13:35:40 raspi4 esphome[30888]:     self.proc = subprocess.Popen(*args, **kwargs)
Sep 30 13:35:40 raspi4 esphome[30888]:   File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
Sep 30 13:35:40 raspi4 esphome[30888]:     restore_signals, start_new_session)
Sep 30 13:35:40 raspi4 esphome[30888]:   File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
Sep 30 13:35:40 raspi4 esphome[30888]:     raise child_exception_type(errno_num, err_msg, err_filename)
Sep 30 13:35:40 raspi4 esphome[30888]: FileNotFoundError: [Errno 2] No such file or directory: 'esphome': 'esphome'

I can still connect with a browser and edit the .yaml files but I cannot validate and upload.

This is my service file content:

[Unit]
Description= ESPHome Dashboard
After=network.target

[Service]
WorkingDirectory=/home/homeassistant/.homeassistant/esphome
User=pi
ExecStart=/home/pi/.local/bin/esphome /home/homeassistant/.homeassistant/esphome/ dashboard
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

Any help would be appreciated.
Thanks

Finally I found a solution in this forum. I needed to add the environment path to the [Service]
section:

Environment="PATH=/home/pi/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
2 Likes