Accessing Python In Hyper-V Home assistant OS image

Tags: #<Tag:0x00007f328445eeb8>

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])

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: 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

But I cant seem to figure out how to use it for my scripts.

Any advice would be great, as this is proving to be more challenging than I had hoped.

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:

find / -type f -name python 2> /dev/null

To find all instances of python.

I appreciate the help. I was able to find two locations containing a python executable

$ find / -type f -name python 2> /dev/null

But, trying to run any of them gives me the following permission denied error:

/ $ /config/comcast/xfinity-usage
-bash: /config/comcast/xfinity-usage: /usr/share/bash-completion/helpers/python: bad interpreter: Permission denied
/ $ /config/comcast/xfinity-usage
-bash: /config/comcast/xfinity-usage: /usr/share/bash-completion/completions/python: bad interpreter: Permission denied

There are also some pyvenv executables in the completions dir, but the same error

/ $ /config/comcast/xfinity-usage
-bash: /config/comcast/xfinity-usage: /usr/share/bash-completion/completions/pyvenv-3.8: bad interpreter: Permission denied

None of those are what you’re after unfortunately. Those are for bash completion as mentioned.

You might need to use "python*" as your query, so:

find / -type f -name "python*" 2> /dev/null

This is the results:

 $ find / -type f -name "python*" 2> /dev/null