Python script as shell command - import problem

I run HA (v0.100.2 right now) successfully in Docker for ARM64.
I’d like to run my python script (that reads data via RS485) which has some imports:

import minimalmodbus
import paho.mqtt.client as mqtt
import paho.mqtt.publish as pub

So when I call it from container I’m getting import errors like that:

# python3 /config/sdm630/sdm630_to_mqtt.py
Traceback (most recent call last):
  File "/config/sdm630/sdm630_to_mqtt.py", line 2, in <module>
    import minimalmodbus
ModuleNotFoundError: No module named 'minimalmodbus'

How to deal with it? I can install these modules manually but it’s temporary solution until I upgrade HA - container will be recreated then and modules will gone away…

You can’t import in a python script. The environment is limited. I suggest moving to appdeamon or make a custom component.

I’m aware of this limitation and that’s why I use shell_command component.

Ah ok, then you need to fork the HA container, add your files and upgrade from that forked container.

Or move to hassbian in a venv and never deal with this.