getting error while importing cv2 in python2

asked 2019-03-28 04:16:29 -0600

Nitinnaik gravatar image

I have successfully built opencv with gstreamer using CMAKE and Visual studio c++. cv2.pyd file is also created in build/lib/release folder I have installed the library by build the INSTALL.csproj in visual studio.

But getting error while import cv2 into python, Here is error text:

Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\cv2__init__.py", line 91, in <module> bootstrap() File "C:\Python27\lib\site-packages\cv2__init__.py", line 81, in bootstrap import cv2 ImportError: DLL load failed: The specified module could not be found.

I have given the gstreamer as well as \build\install\x86\vc15\bin\ and build\install\x86\vc15\lib path also. Please help me on this..

edit retag flag offensive close merge delete

Comments

is there a cv2.pyd in your site-packages ? if not, did you try to copy it manually there ?

did you build it with cmake -DBUILD_SHARED_LIBS=OFF ? else it will rely on otheropencv dll's on the PATH

berak gravatar imageberak ( 2019-03-28 05:26:54 -0600 )edit

I tried your approach. I built it with cmake -DBUILD_SHARED_LIBS=OFF and also cv2.pyd is present in the site-packages, still it is giving same error:

C:\Users\ADMIN>python Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\cv2__init__.py", line 89, in <module> bootstrap() File "C:\Python27\lib\site-packages\cv2__init__.py", line 79, in bootstrap import cv2 ImportError: DLL load failed: The specified module could not be found.

Nitinnaik gravatar imageNitinnaik ( 2019-03-28 06:34:22 -0600 )edit

Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32

32/64bit problem ? can you go back to Visual Studio, and check, if you accidentally built 64bit binaries ?

berak gravatar imageberak ( 2019-03-28 08:23:10 -0600 )edit
1

I have Windows 10 32 bit machine and I have selected Wn32 for built.

WITH_GSTREAMER=OFF in CMAKE I am able to import cv2.

But WITH_GSTREAMER=ON I am getting the error that ImportError: DLL load failed: The specified module could not be found.

Nitinnaik gravatar imageNitinnaik ( 2019-03-28 08:41:16 -0600 )edit