71

When I run

!pip install imgaug==0.4.0

the following is the output

Collecting imgaug==0.4.0
  Using cached https://files.pythonhosted.org/packages/66/b1/af3142c4a85cba6da9f4ebb5ff4e21e2616309552caca5e8acefe9840622/imgaug-0.4.0-py2.py3-none-any.whl
Requirement already satisfied: Pillow in /opt/conda/envs/Python-3.6/lib/python3.6/site-packages (from imgaug==0.4.0) (5.4.1)
Requirement already satisfied: numpy>=1.15 in /opt/conda/envs/Python-3.6/lib/python3.6/site-packages (from imgaug==0.4.0) (1.15.4)
Collecting Shapely (from imgaug==0.4.0)
  Using cached https://files.pythonhosted.org/packages/9d/18/557d4f55453fe00f59807b111cc7b39ce53594e13ada88e16738fb4ff7fb/Shapely-1.7.1-cp36-cp36m-manylinux1_x86_64.whl
Requirement already satisfied: six in /opt/conda/envs/Python-3.6/lib/python3.6/site-packages (from imgaug==0.4.0) (1.12.0)
Requirement already satisfied: matplotlib in /opt/conda/envs/Python-3.6/lib/python3.6/site-packages (from imgaug==0.4.0) (3.0.2)
Collecting scikit-image>=0.14.2 (from imgaug==0.4.0)
  Using cached https://files.pythonhosted.org/packages/0e/ba/53e1bfbdfd0f94514d71502e3acea494a8b4b57c457adbc333ef386485da/scikit_image-0.17.2-cp36-cp36m-manylinux1_x86_64.whl
Requirement already satisfied: imageio in /opt/conda/envs/Python-3.6/lib/python3.6/site-packages (from imgaug==0.4.0) (2.4.1)
Collecting opencv-python (from imgaug==0.4.0)
  Using cached https://files.pythonhosted.org/packages/77/f5/49f034f8d109efcf9b7e98fbc051878b83b2f02a1c73f92bbd37f317288e/opencv-python-4.4.0.42.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: scipy in /opt/conda/envs/Python-3.6/lib/python3.6/site-packages (from imgaug==0.4.0) (1.2.0)
Requirement already satisfied: cycler>=0.10 in /opt/conda/envs/Python-3.6/lib/python3.6/site-packages (from matplotlib->imgaug==0.4.0) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/envs/Python-3.6/lib/python3.6/site-packages (from matplotlib->imgaug==0.4.0) (1.0.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /opt/conda/envs/Python-3.6/lib/python3.6/site-packages (from matplotlib->imgaug==0.4.0) (2.3.1)
Requirement already satisfied: python-dateutil>=2.1 in /opt/conda/envs/Python-3.6/lib/python3.6/site-packages (from matplotlib->imgaug==0.4.0) (2.7.5)
Collecting tifffile>=2019.7.26 (from scikit-image>=0.14.2->imgaug==0.4.0)
  Using cached https://files.pythonhosted.org/packages/3c/13/4f873f6b167c2e77288ce8db1c9f742d1e0e1463644e2df4e3bd3c40a422/tifffile-2020.8.25-py3-none-any.whl
Requirement already satisfied: networkx>=2.0 in /opt/conda/envs/Python-3.6/lib/python3.6/site-packages (from scikit-image>=0.14.2->imgaug==0.4.0) (2.2)
Collecting PyWavelets>=1.1.1 (from scikit-image>=0.14.2->imgaug==0.4.0)
  Using cached https://files.pythonhosted.org/packages/59/bb/d2b85265ec9fa3c1922210c9393d4cdf7075cc87cce6fe671d7455f80fbc/PyWavelets-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Requirement already satisfied: setuptools in /opt/conda/envs/Python-3.6/lib/python3.6/site-packages (from kiwisolver>=1.0.1->matplotlib->imgaug==0.4.0) (40.8.0)
Requirement already satisfied: decorator>=4.3.0 in /opt/conda/envs/Python-3.6/lib/python3.6/site-packages (from networkx>=2.0->scikit-image>=0.14.2->imgaug==0.4.0) (4.3.2)
Building wheels for collected packages: opencv-python
  Building wheel for opencv-python (PEP 517) ... -

But the Building wheel for opencv-python (PEP 517) ... - runs forever, how to resolve this problem?

6
  • What machine and what is your definition of "forever"?
    – Klaus D.
    Commented Aug 31, 2020 at 11:20
  • 1
    This happens to me in "pip install opencv-python", the latest version seemed to be opencv-python-4.4.0.44 Commented Oct 3, 2020 at 21:34
  • 24
    It does not run forever. OpenCV is a very heavy C++ library and it takes usually 10+ minutes to compile it from sources even on modern CPUs. You can avoid this by upgrading your pip to a version which supports modern manylinux2014 pre-built wheels: pip install --upgrade pip
    – skvark
    Commented Oct 13, 2020 at 12:54
  • just go for a coffee, it took more like 20min in my i5-4210U @ 1.70GHz with 6GB
    – toto_tico
    Commented Nov 17, 2020 at 15:15
  • 7
    If all tips wont work, you might want to run pip with the -v or -vvv switch, which enables verbose output (the more v's, the more output). This will definetly not speed up the process, but it will show you what exactly is happening. This can be much more reassuring than sitting in front of a black box for hours, not knowing if it will work at all... Commented Jan 27, 2022 at 13:26

13 Answers 13

68

i had the same problem, everything worked out:

pip install --upgrade pip setuptools wheel
1
  • 3
    Maybe running pip install --upgrade pip after pip install --upgrade pip setuptools wheel is a good practice too; to resolve any conflict. I did both, and the problem was resolved.
    – Mohd
    Commented Apr 19, 2021 at 15:42
27

Solve by install openCV-Python explicitly first using !pip install opencv-python==4.3.0.38 If this version does not exist it would open version that exist.

Then you can run !pip install imgaug.

As the older version of opencv-python doesn't require wheel compilation.

1
  • 27
    The new version does not require compilation either. You just need to upgrade your pip before installing opencv-python: pip install --upgrade pip
    – skvark
    Commented Aug 31, 2020 at 12:21
23

Small PSA for anyone trying to run the command pip install opencv-contrib-python on a Raspberry Pi.

If it seems stuck, know that the installation will take 2 hours.

Edit: Google led me here, and it's very hard to find this information otherwise. So yeah.

3
  • 1
    Thank you for this! The wheels do be turning but very slow
    – PotatoSoop
    Commented May 26, 2023 at 18:15
  • 1
    thank you! pi3 b running for over an hour, I guess I keep waiting :D
    – xmael91nt
    Commented Nov 10, 2023 at 17:31
  • 1
    Yes. I added --verbose to see if there's any progress. It was helpful. Commented Feb 8 at 15:01
9

I am using Docker with Ubuntu, and I encountered the same issue. The problem is that the build process is quite large. To make things smoother, run the installation with the --verbose flag:

pip install opencv-python --verbose
1
  • 2
    How long did it last?
    – sk1me
    Commented Aug 25, 2023 at 19:07
6

Side note: For those looking to see more detail of the installation progress, you can install with the highest level of verbosity. Seeing the compilation progress was very helpful.

pip install opencv-python -vvv
3

If you are using Raspberry pi then use command pip install opencv-python==4.5.3.56 then update numpy using pip install -U numpy and then install package you need to install which has OpenCV dependency.

2

For me on Windows, it was interference from 360 Total security. Disabling it solved all the issues I had.

2
  • Having the same issue I guess. How do you see the unterferences and how did you disable it?
    – laymelek
    Commented Nov 7, 2023 at 16:34
  • At one point while I was installing I saw a message from the antivirus pop up that they deleted some suspicious files. Turns out those files were required for pip to install the packages. I exited 360 Total Security from its background task and every package I had this issue with before suddenly started working. Commented Nov 8, 2023 at 17:48
0

It happened to me as well while i was downloading pip install opencv-python Just go to the preferences, go to python interpreter and then check for the wheels package and delete it by clicking on it and pressing the minus mark next to the add mark. This error comes because to download it, the package should first build thousands of dependencies for wheels as opencv is a big package. If you uninstall wheels then they don't have to build dependencies. Note that uninstalling wheels won't affect anything in the code. I have a mac and use pycharm as the IDE so, i am not sure whether it works on other devices.

This is a image of the the interpreter that is after uninstalling wheels

0

In my case I created a new condo env that's working with python3.11 and there's no any error.Use anaconda env with following this instruct

conda create --name your_environment_name python=3.11
conda activate your_environment_name

and install your dependencies

0

YMMV : Mine was taking ages, but it turns out I had VS Code that was using the interpreter I was trying to install the package to. Closing VS immediately solved the issue.

1
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Aug 19, 2023 at 1:11
0

I had exactly the same problem with installing the opencv-python package on my RPI 3B with the Bullseye light OS.

Since the pip install opencv-python or pip install opencv-contrib-python command didn't work, I followed the official installation guide for the opencv-python package and followed the installation from the chapter "Building OpenCV from source". The make command also took about 3 hours, but finally it works.

0

go to this addr https://pypi.org/project/opencv-contrib-python/, click 'release-history' find the version you need and download wheel file accordingly (cp36 means python version 3.6, i686 means 32bit, x86 means 64 bit), then pip install /path/to/wheel to avoid build that wheel file

-2

python -m pip install --upgrade opencv-python --user

1
  • 4
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – lemon
    Commented May 17, 2022 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.