Python venv not working from shell_command

Hello,

I try to create a shell_command, that executes my custom python script, which uses the python package “gkeepapi”. So I created a venv and installed the dependency there but all my attempts to execute the script fail with the message
ModuleNotFoundError: No module named 'gkeepapi'

I have Home assistant running on my Raspberry PI with HAOS.

I tried:

  • running the script directly (failing obviously, because module is missing)
  • using “source <script_path>/venv/bin/activate && python3 <script_path>/main.py”
  • using a .sh script with the command above in it
  • running “<script_path>/venv/bin/python3 <script_path>/main.py”
  • including pip3 install gkeepapi inside the script itself, this returns that it’s already installed but the next command, which should execute the script says “No module named ‘gkeepapi’” again

If more information is needed, please tell me

You might want to consider using appdeamon:

https://appdaemon.readthedocs.io/en/latest/

I ended up coding a custom component. Appdaemon was not the right thing I wanted but could be useful for future ideas

1 Like