gordon77
Posts: 4304
Joined: Sun Aug 05, 2012 3:12 pm

installing opencv in python3 ? [SOLVED]

Sun Jan 27, 2019 4:34 pm

With the impending end to python2 I want to find a good/quick method to install opencv in python3.

I tried ths https://www.pyimagesearch.com/2018/09/1 ... ll-opencv/

If I use the option1 I get

Code: Select all

Traceback (most recent call last):
  File "/home/pi/eyes4d.py", line 3, in <module>
    import cv2
  File "/usr/local/lib/python3.5/dist-packages/cv2/__init__.py", line 3, in <module>
    from .cv2 import *
ImportError: libcblas.so.3: cannot open shared object file: No such file or directory
If I try option 2 I get no module cv2 found

Anyone know what's going wrong ?
Last edited by gordon77 on Mon Jan 28, 2019 9:04 am, edited 1 time in total.

gordon77
Posts: 4304
Joined: Sun Aug 05, 2012 3:12 pm

Re: installing opencv in python3 ?

Mon Jan 28, 2019 9:04 am

I fixed it by running...

Code: Select all

sudo apt-get install libcblas-dev
sudo apt-get install libhdf5-dev
sudo apt-get install libhdf5-serial-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev
sudo apt-get install libqtgui4
sudo apt-get install libqt4-test
some were already installed

gordon77
Posts: 4304
Joined: Sun Aug 05, 2012 3:12 pm

Re: installing opencv in python3 ? [SOLVED]

Mon Jan 28, 2019 9:29 am

this does the whole installation...

Code: Select all

sudo pip3 install opencv-python 
sudo apt-get install libcblas-dev
sudo apt-get install libhdf5-dev
sudo apt-get install libhdf5-serial-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev 
sudo apt-get install libqtgui4 
sudo apt-get install libqt4-test

mattmiller
Posts: 2136
Joined: Thu Feb 05, 2015 11:25 pm

Re: installing opencv in python3 ? [SOLVED]

Mon Jan 28, 2019 9:47 am

Could I ask what version of OpenCV does this give you?


mattmiller
Posts: 2136
Joined: Thu Feb 05, 2015 11:25 pm

Re: installing opencv in python3 ? [SOLVED]

Mon Jan 28, 2019 5:08 pm

mm-not too much behind - saves having to spend hours compiling it

It may be the thing that gets me to move over to Python3 :)

gordon77
Posts: 4304
Joined: Sun Aug 05, 2012 3:12 pm

Re: installing opencv in python3 ? [SOLVED]

Mon Jan 28, 2019 6:03 pm

Same here. Compiling it for python3 was very time consuming.

hofo
Posts: 2
Joined: Fri Oct 04, 2019 12:19 pm

Re: installing opencv in python3 ? [SOLVED]

Fri Oct 04, 2019 12:22 pm

I'm using a Raspberry PI 3b+ and installed all the packages mentioned above after I got the same error.

Now I get this error:

Code: Select all

import cv2

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
ImportError: numpy.core.multiarray failed to import

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-c8ec22b3e787> in <module>
----> 1 import cv2

/usr/local/lib/python3.5/dist-packages/cv2/__init__.py in <module>
      1 import importlib
      2 
----> 3 from .cv2 import *
      4 from .data import *
      5 

ImportError: numpy.core.multiarray failed to import

Is there a solution for this?

Thanks

hofo

gordon77
Posts: 4304
Joined: Sun Aug 05, 2012 3:12 pm

Re: installing opencv in python3 ? [SOLVED]

Mon Oct 21, 2019 12:36 pm

Try...

Code: Select all

sudo apt-get install python3-opencv
sudo apt-get install libhdf5-dev
sudo apt-get install libhdf5-serial-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev 
sudo apt-get install libqtgui4 
sudo apt-get install libqt4-test

Return to “Troubleshooting”