Import homeassistant.config not available in docker

Home Assistant release (hass --version): 0.62.0

Python release (python3 --version): 3.6.4

Component/platform: Docker running on Ubuntu

Description of problem:
in a python script:
import homeassistant.config
import homeassistant.remote
do not work in a docker container.

Expected:
The imports work.

Traceback (if applicable):

python z-wave-graph.py --ssl --port 443

Traceback (most recent call last):
File “z-wave-graph.py”, line 23, in
import homeassistant.config
ModuleNotFoundError: No module named ‘homeassistant’
Additional info:
Trying to use this:

This is the file trying to run:


Failing on line 23, will next fail on 24.

These are the Loaded modules:

I posted this issue on github. I’m just trying to figure out how to import homeassistant.config and .remote in the docker container to use this script. Any help would be appreciated.

Thanks

Any suggestions?

I had the same issue and had to run the file from /usr/src/app

1 Like

@kylerw In order to keep the file out of the docker container and in the /config dir i just added this:

sys.path.append('/usr/src/app')

below:

import sys

and it fixed me right up.

The header now looks like this:

#! /usr/bin/env python3

import argparse
import datetime
import json
import os.path
import sys
sys.path.append('/usr/src/app')

But thank you so much for pointing me in the right direction. Ive been searching for days!

1 Like