VSCode test run No module named 'homeassistant'

I’m trying to use Studio Code Server to work with HomeAssistant python files, but it cannot find any build-in components. I created the followin test.py file:

from homeassistant.components.device_tracker import (
    DOMAIN, PLATFORM_SCHEMA, DeviceScanner)

But when I run it, I can see the following error:

Exception has occurred: ModuleNotFoundError
No module named ‘homeassistant’

Screenshot is attached. I’m quite newbie in python. How can I resolve this error?

Thank you in advance!

1 Like