I am having some issues accessing python to run scripts on my instance of HomeAssistant OS Hyper-V image.
I am trying to run a script from an automation found here (Xfiniy-usage) and the zip with the xfinity-usage file
#!<path to hass>/bin/python3.7
# -*- coding: utf-8 -*-
import re
import sys
from xfinity_usage.xfinity_usage import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
But when I go to run this I get the following error:
./xfinity-usage: <path: bad interpreter: No such file or directory
I see that it was becasue I wasn’t pointing to a dir, so I tried looking for python on ssh and could not find it
$ python ––version
-bash: python: command not found
I commented out the first line of the xfinity-usage that was the version of python to use?, and then I get these errors:
./xfinity-usage
./xfinity-usage: line 3: import: command not found
./xfinity-usage: line 4: import: command not found
./xfinity-usage: line 5: from: command not found
./xfinity-usage: line 7: syntax error near unexpected token `('
./xfinity-usage: line 7: ` sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])'
I looked at the web ui, and under system info I can see that home assistant is running python 3.8.5
This isn’t how you search for Python that is within virtual environments.
This will search all the files in your $PATH (run echo $PATH to see) looking for something executable called python.
I am not sure where your HA stores it’s virtual environment, but perhaps you can run: