Speedtest not working with Docker Image

Just migrated my setup to a new machine running Ubuntu. I installed the Docker Image 0.45 and everything except speedtest is running perfectly (Also ZWave). My previous installation was a AIO installation.

Before moving to a Docker installation SpeedTest was working fine, and I have not changed my configuration files, but now I get the below error.

Error is:
2017-05-22 21:30:00 ERROR (<concurrent.futures.thread.ThreadPoolExecutor object at 0x7f189cc95ac8>_1) [homeassistant.components.sensor.speedtest] Error executing speedtest: Command '['/usr/local/bin/python', '/usr/local/lib/python3.6/site-packages/speedtest.py', '--simple', '--server', '5669']' returned non-zero exit status 1.

same here - I upgraded and am getting speediest error

I also have the speedtest plugin set up with home-assistant running in a Docker container.

Which port did you expose? Or did you set it up as --net=host?

I used --net=host.

Try to run /usr/local/bin/python /usr/local/lib/python3.6/site-packages/speedtest.py --server 5669 from inside your docker container.
Not giving the --simple argument should give you more information about what’s the error. (see here for more information).

To connect to the docker, use this:
docker exec -it CONTAINER-NAME bash

While you’re at it, try to run /usr/local/bin/python --version from inside the container to see if the python command is associated with Python 3.6 (or 3.6.1)

The speed test python library that HA uses is only compatible with python 2.6-3.5 so that is why it is complaining. Not sure how to fix but I’ve asked in the dev chat.

I use Python 3.6.1 and the library work fine. My speed is still refreshed like expected.

I know the package index page show a compatibility up to Python 3.5 but I assume it’s only because they didn’t test it with Python 3.6.

# /usr/local/bin/python /usr/local/lib/python3.6/site-packages/speedtest.py --server 5669
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/speedtest.py", line 19, in <module>
    import re
  File "/usr/local/lib/python3.6/re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
# /usr/local/bin/python --version                                                        
Python 3.6.1

Doesn’t work for me.

I get exactly the same result as keatontaylor when running the commands inside the Docker Container

Receiving similar errors since the upgrade to .45 with speedtest no longer functioning, running docker on syno nas.

You could try with a new container and with python 3.5 to see if that solve the problem.

anyone have luck getting this fixed wit update .46?

Nope, it’s still broken.

So after some googling it looks like the issue is an incompatibility with the enum34 library and python 3.6. Here is what I did to fix my issue, however it may break other things so please use at your own risk! So I connected to my docker container using toullloup’s instructions:
docker exec -it CONTAINER-NAME bash
After connecting, run
pip freeze
see that enum34==1.1.6 or similar is in the dependencies list
pip uninstall enum34
restart the docker container. This fixed my issue, however removing dependencies like this can have unintended consequences, so be careful. I will try to spend some more time this week looking into this to see if I can suggest a long term fix for the docker image for future releases, but don’t know enough about how HA works under the hood for that yet. Hope this helps!

1 Like

I never had problem running SpeedTest in my container (Python 3.6.1), I also see that I don’t have enum34 installed, I only have:
enum-compat==0.0.2

pip freeze result:

aiohttp==2.0.7
appdirs==1.4.3
astral==1.4
async-timeout==1.2.1
chardet==3.0.2
enum-compat==0.0.2
homeassistant==0.45.0
Jinja2==2.9.6
MarkupSafe==1.0
multidict==2.1.5
mysqlclient==1.3.10
netdisco==1.0.0rc3
netifaces==0.10.4
packaging==16.8
pyparsing==2.2.0
pytz==2017.2
PyYAML==3.12
requests==2.14.2
six==1.10.0
typing==3.6.1
voluptuous==0.10.5
yarl==0.10.2
zeroconf==0.19.0

removing enum34 worked for me. Haven’t seen anything acting up with that dependency removed yet.

I haven’t had any issues yet as well. It’s strange that @touliloup did not have the dependency, I don’t know enough about how docker works to understand that, but it would seem that the dependency is not necessary and is just left over from previous versions.

I’ve created my own Docker container, I don’t like the main docker container. It just install too much dependencies and unnecessary script/fix (for me).

My Docker container simply proceed to a standard installation of home-assistant.

Here is the Dockerfile I use:

FROM python:3.6
MAINTAINER Touli Loup <[email protected]>

VOLUME /config
RUN python3 --version

RUN echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
RUN apt-get update && apt-get upgrade -y && apt-get install -y net-tools nmap git && apt-get install -y certbot -t jessie-backports
RUN pip3 install --upgrade mysqlclient
RUN pip3 install netdisco==1.0.0rc3
RUN pip3 install --upgrade homeassistant

COPY ./docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]

docker-entrypoint.sh:

#!/bin/bash

certbot certonly --standalone -q --agree-tos --preferred-challenges http-01 --email [email protected] -d blablabla.duckdns.org
hass --config /config

build command:
docker build --no-cache -t hass/hass:latest .

run command:

docker run -d --name="home-assistant" \
--restart=unless-stopped \
-v $(pwd)/config:/config \
-v /etc/localtime:/etc/localtime:ro \
--net=host \
--log-opt max-size=10m \
hass/hass

Ah that makes sense. It definitely seems that the enum34 dependency should be removed then.

Yes, I guess it’s a transitive dependency as there is no direct reference to it in the github repo.

And why does the github docker always install every dependencies? The missing one will be installed by hass on startup, no?

I understand the point if it’s only a development container, it allow to detect dependencies conflict faster, but it’s not appropriate for production usage.

It’s really a lot of dependencies, 275!!

https://raw.githubusercontent.com/home-assistant/home-assistant/dev/requirements_all.txt