Home Assistant Docker image (0.98.5) on Ubuntu 18.04.3 will no longer allow the manual install of opencv-python

For a while now, I have been manual installing opencv-python into my docker image by bashing into it using:
sudo docker exec -it home-assistant /bin/bash

and running

pip install opencv-python

For the last few versions of HA, I am getting the error:

ERROR: Could not find a version that satisfies the requirement opencv-python (from versions: none)

I believe I have narrowed this problem down to the docker image not supporting the manylinux1 wheels and instead looking for linux_x86_64 tagged wheels (for which there are none for opencv-python).

When I run the following command from within docker

python3 -c "import wheel.pep425tags as w; print(w.get_supported())"

I get

[('cp37', 'cp37m', 'linux_x86_64'), ('cp37', 'abi3', 'linux_x86_64'), ('cp37', 'none', 'linux_x86_64'), ('cp36', 'abi3', 'linux_x86_64'), ('cp35', 'abi3', 'linux_x86_64'), ('cp34', 'abi3', 'linux_x86_64'), ('cp33', 'abi3', 'linux_x86_64'), ('cp32', 'abi3', 'linux_x86_64'), ('cp37', 'none', 'any'), ('cp3', 'none', 'any'), ('cp36', 'none', 'any'), ('cp35', 'none', 'any'), ('cp34', 'none', 'any'), ('cp33', 'none', 'any'), ('cp32', 'none', 'any'), ('cp31', 'none', 'any'), ('cp30', 'none', 'any'), ('py3', 'none', 'linux_x86_64'), ('py37', 'none', 'any'), ('py3', 'none', 'any'), ('py36', 'none', 'any'), ('py35', 'none', 'any'), ('py34', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')]

Then I try to find out what linux wheels are available by running:

pip3 -v install opencv-python | grep linux | grep 4.1.1.26 | grep cp36

Which gives me the following results:

    Skipping link: none of the wheel's tags match: cp36-cp36m-manylinux1_i686: https://files.pythonhosted.org/packages/25/e6/eb2bdafab7e4707177760489812de21d68bdee98621b3fd425dac572c0e5/opencv_python-4.1.1.26-cp36-cp36m-manylinux1_i686.whl#sha256=db8313d755962a7dd61e5c22a651e0743208adfdb255c6ec8904ce9cb02940c6 (from https://pypi.org/simple/opencv-python/)
    Skipping link: none of the wheel's tags match: cp36-cp36m-manylinux1_x86_64: https://files.pythonhosted.org/packages/5e/7e/bd5425f4dacb73367fddc71388a47c1ea570839197c2bcad86478e565186/opencv_python-4.1.1.26-cp36-cp36m-manylinux1_x86_64.whl#sha256=67d994c6b2b14cb9239e85dc7dfa6c08ef7cf6eb4def80c0af6141dfacc8cbb9 (from https://pypi.org/simple/opencv-python/)

I believe the opencv_python-4.1.1.26-cp36-cp36m-manylinux1_x86_64.whl should be compatible with my system, but I can’t figure out why it’s not supported by pip3 or how to modify the pip3 supported tags to force it to install.

Tensorflow seems to be slower and less reliable without opencv. Any help would be appreciated.

BTW, when I run:

pip3 install opencv-python 

from outside of the docker container works just fine and picks up the manylinux1 wheel.

pip3 install opencv-python

results in:

Collecting opencv-python
  Using cached https://files.pythonhosted.org/packages/5e/7e/bd5425f4dacb73367fddc71388a47c1ea570839197c2bcad86478e565186/opencv_python-4.1.1.26-cp36-cp36m-manylinux1_x86_64.whl
Collecting numpy>=1.11.3 (from opencv-python)
  Using cached https://files.pythonhosted.org/packages/e5/e6/c3fdc53aed9fa19d6ff3abf97dfad768ae3afce1b7431f7500000816bda5/numpy-1.17.2-cp36-cp36m-manylinux1_x86_64.whl
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.17.2 opencv-python-4.1.1.26

As you’ve stated, you’re running Ubuntu on the host.

The docker runs Alpine Linux.

Thanks you, that makes sense. I would have been pulling out my hair … if I had any.

Do you know if a change was recently made moving to Alpine in the Docker, or did opencv-python drop Alpine from their supported wheels?

Thank you.

Hopefully this thread will show up if someone Googles the same issue and save them the troubleshooting involved.

Buried in the 0.98 blog post:

As you have found - the move from Debian to Alpine changes the libraries (GNU to Musl) and many python packages are not built for this (due to manywheel being for GNU). I was able to follow the below instruction to successfully build openCV on my system from source - but this is not worth the work to do every time HA updates.

https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html

I’m a novice, so I can follow instructions decently, but do not have the knowledge of what would need to be done to make this a package available on the python library site.

I hope this helped!
Cheers!
DeadEnd