I am using Raspbian Stretch on my RPi 3, I wanted to install OpenCV on it.
I did this before by following the instructions detailed here .
The problem is that this takes a very long time.
Lately, I've been looking in the internet, so I found in this link that installing Opencv only needs to run these commands pip install opencv-python
and pip install opencv-contrib-python
. I tried it on Ubuntu with my PC and it worked well.
So my question is: is it possible to install Opencv on a RPi 3 by just running these commands instead of compiling it from source?
Asked
Active
Viewed 2,916 times
3

singrium
- 135
- 1
- 8
-
I really do not know , my fault, how to respond, but who or what is stopping you to try it ? Secondly - if the "manual: states it will take OpenCV time to install due to dependencies - why cannot just accept that? – Jan Hus Aug 30 '18 at 13:58
-
Unfortunately, it is a bit late now.. I am already in the last step of the 'usual' method which is compiling from source. So at least I have to wait till it finishes to try this one. – singrium Aug 30 '18 at 14:02
-
Have you favorite snack / beverage in the meantime. Cheers – Jan Hus Aug 30 '18 at 14:03
-
As I read in this link: https://raspberrypi.stackexchange.com/questions/77307/found-a-pypi-package-for-opencv-contrib-but-cant-install-using-pip, precompiled binaries work only for some specific architectures (X86 and X86_64 but not ARM), which means that the only available solution to install Opencv on RPi is to compile it from source. – singrium Aug 30 '18 at 14:12
-
1@singrium: precompiled wheels of opencv-python and opencv-contrib-python for arm / python 3 are available from piwheels (www.piwheels.org) – Dirk Aug 30 '18 at 14:21
-
Sometime RTFM REALLY answers questions. LOL ! Actually I was wondering if cross-compiling OpenCV would work "better" instead of running it on RPi, – Jan Hus Aug 30 '18 at 14:28
-
@Dirk: Thank you, piwheels saved me a lot of time! – singrium Aug 30 '18 at 14:30
1 Answers
5
Precompiled wheels of opencv-python and opencv-contrib-python for arm / python 3 are available from piwheels (www.piwheels.org). On current Raspbian Stretch this already pre-configured.
On other distros (such as Raspbian Jessie) it can easily be added by creating the file '/etc/pip.conf' containing:
[global]
extra-index-url=https://www.piwheels.org/simple
-
Di you try installing Opencv using piwheels before? As I said before, I am in the last step of compiling Opencv from source and I am afraid that if I abort it now and try piwheels it will not work. – singrium Aug 30 '18 at 15:08
-
Not 'in anger', meaning I downloaded it, but I cannot test if it's actually working ATM. Maybe you can create a virtual environment and try to download it in that environment. – Dirk Aug 30 '18 at 15:22
-
This doesn’t work either; same “no matching distribution error” – Noah Pentecost Nov 22 '18 at 20:39
-
@NoahPentecost on what model Pi / OS + version / Python version? And what is the exact command you use? – Dirk Nov 22 '18 at 20:57
-
This worked on a RasPi 3 Model B v1.2, under Stretch. This is a fresh install, and I do not understand the claim that Stretch checks PiWheels out of the box. If really pre-configured, the system images we get are broken. Anyway, thanks @Dirk for compiling a solution (note that this solution checks PiWheel after, not before PyPi, as expected in some Stretch documentations). – Eric Platon Jan 30 '19 at 00:52
-
Another comment: PiWheels provide OpenCV 3.4.4 at time of writing. For OpenCV 4.x, only install from source is available now. Sample install tutorial. – Eric Platon Jan 30 '19 at 00:54