5

Building wheel for opencv-python keeps running for a very long time, while building the docker image. What can be done to make this run faster?

RUN pip install opencv-python

Collecting opencv-python
  Downloading opencv-python-4.6.0.66.tar.gz (90.3 MB)

...

  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: opencv-python, numpy
  Building wheel for opencv-python (pyproject.toml): started
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...   
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...
  Building wheel for opencv-python (pyproject.toml): still running...
Rpj
  • 5,348
  • 16
  • 62
  • 122
  • how many minutes did you wait ? – Yunus Temurlenk Sep 13 '22 at 08:54
  • 1
    seems like duplicate of [\`Building wheel for opencv-python (PEP 517) ... -\` runs forever](https://stackoverflow.com/questions/63669752/building-wheel-for-opencv-python-pep-517-runs-forever) – Yunus Temurlenk Sep 13 '22 at 08:54
  • @YunusTemurlenk its like 30-45 minutes and we also upgraded pip within Dockerfile – Rpj Sep 13 '22 at 09:09
  • OpenCV is big. have some patience. and do not run this on a resource-constrained device like a raspberry, or if you do, expect it to take a while. -- why do you need to build at all? official opencv-python packages are binary and come for many architectures. – Christoph Rackwitz Sep 13 '22 at 10:20
  • @ChristophRackwitz this is on a t2.large machine and its still slow – Rpj Sep 13 '22 at 11:23
  • what is a "t2.large"? it's nothing related to OpenCV or Python, as far as I can tell. anyway, does the link provided by Yunus help? – Christoph Rackwitz Sep 13 '22 at 11:25
  • No it doesn't, t2.large is an AWS EC2 8GB instance – Rpj Sep 13 '22 at 17:05

2 Answers2

11

I have also encountered the same issue in a low-level machine. Actually it takes long time but there is nothing wrong in backend. Run the installation command with --verbose so you can see what is happening actually behind.

When I have run the code:

sudo pip install opencv-python --verbose

I am able to track the process and also check the percentage of installation. So after 30 minutes it was still 30% completed - :) a really low machine however we sometimes need to install it - After little patience, 2 hours later it is done, so whoever meeting this error this may help them.

Yunus Temurlenk
  • 4,085
  • 4
  • 18
  • 39
0

I had the same problem - In verbose mode it stuck on tests and .c installations.

I changed my py version from 3.6 to 3.8 and the installation finished in seconds!