Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error importing cv2 after compiling OpenCV from source (Python)

Hello guys, I am following two tutorials on Youtube on how we can compile OpenCV (4.4.0) from source using CMake and Visual Studio 2019. And currently, I'm using Windows with CUDA 10.1.

Tutorial 1: https://www.youtube.com/watch?v=_fqpYLM6SCw&t=331s&ab_channel=TheAIGuy Tutorial 2: https://www.youtube.com/watch?v=tjXkW0-4gME&t=1s&ab_channel=TheCodingBug

After following step by step, including "Build" for the ALL_BUILD and "INSTALL" it, I couldn't use the OpenCV in the terminal, by importing python

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'

I also noticed that after obtaining OpenCV.sln, I do not have the "binding" folder like both of tutorial videos.

image description

The questions are: 1) Does the binding file is really that important ? 2) If its not that important, how can I use the openCV that has been compiled with my Python?

Error importing cv2 after compiling OpenCV from source (Python)

Hello guys, I am following two tutorials on Youtube on how we can compile OpenCV (4.4.0) from source using CMake and Visual Studio 2019. And currently, I'm using Windows with CUDA 10.1.

Tutorial 1: https://www.youtube.com/watch?v=_fqpYLM6SCw&t=331s&ab_channel=TheAIGuy Tutorial 2: https://www.youtube.com/watch?v=tjXkW0-4gME&t=1s&ab_channel=TheCodingBug

After following step by step, including "Build" for the ALL_BUILD and "INSTALL" it, I couldn't use the OpenCV in the terminal, by importing python

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'

I also noticed that after obtaining OpenCV.sln, I do not have the "binding" folder like both of tutorial videos.

image description

The questions are: 1) Does the binding file is really that important ? 2) If its not that important, how can I use the openCV that has been compiled with my Python?

Edited

Below are the outputs from opencv_version_win32.exe

Error importing cv2 after compiling OpenCV from source (Python)

Hello guys, I am following two tutorials on Youtube on how we can compile OpenCV (4.4.0) from source using CMake and Visual Studio 2019. And currently, I'm using Windows with CUDA 10.1.

Tutorial 1: https://www.youtube.com/watch?v=_fqpYLM6SCw&t=331s&ab_channel=TheAIGuy Tutorial 2: https://www.youtube.com/watch?v=tjXkW0-4gME&t=1s&ab_channel=TheCodingBug

After following step by step, including "Build" for the ALL_BUILD and "INSTALL" it, I couldn't use the OpenCV in the terminal, by importing python

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'

I also noticed that after obtaining OpenCV.sln, I do not have the "binding" folder like both of tutorial videos.

image description

The questions are: 1) Does the binding file is really that important ? 2) If its not that important, how can I use the openCV that has been compiled with my Python?

Edited

Below are the outputs from opencv_version_win32.exe

General configuration for OpenCV 4.4.0 =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            C:/Users/user/OpenCV_CUDA/opencv_contrib-4.4.0/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2020-09-22T19:42:44Z
    Host:                        Windows 10.0.18363 AMD64
    CMake:                       3.18.2
    CMake generator:             Visual Studio 16 2019
    CMake build tool:            C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe
    MSVC:                        1923

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (17 files):         + SSSE3 SSE4_1
      SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (31 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (7 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX

  C/C++:
    Built as dynamic libs?:      YES
    C++ standard:                11
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe  (ver 19.23.28107.0)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:fast     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP  /MD /O2 /Ob2 /DNDEBUG
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:fast     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP  /MDd /Zi /Ob0 /Od /RTC1
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
    C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:fast     /MP   /MD /O2 /Ob2 /DNDEBUG
    C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:fast     /MP /MDd /Zi /Ob0 /Od /RTC1
    Linker flags (Release):      /machine:x64  /INCREMENTAL:NO
    Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL
    ccache:                      NO
    Precompiled headers:         YES
    Extra dependencies:          cudart_static.lib nppc.lib nppial.lib nppicc.lib nppicom.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib npps.lib cublas.lib cudnn.lib cufft.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/lib/x64
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 alphamat cnn_3dobj cvv freetype hdf java js julia matlab ovis python2 python3 sfm viz
    Applications:                tests perf_tests apps
    Documentation:               NO
    Non-free algorithms:         NO

  Windows RT support:            NO

  GUI:
    Win32 UI:                    YES
    VTK support:                 NO

  Media I/O:
    ZLib:                        build (ver 1.2.11)
    JPEG:                        build-libjpeg-turbo (ver 2.0.5-62)
    WEBP:                        build (ver encoder: 0x020f)
    PNG:                         build (ver 1.6.37)
    TIFF:                        build (ver 42 - 4.0.10)
    JPEG 2000:                   build Jasper (ver 1.900.1)
    OpenEXR:                     build (ver 2.3.0)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES
    PFM:                         YES

  Video I/O:
    DC1394:                      NO
    FFMPEG:                      YES (prebuilt binaries)
      avcodec:                   YES (58.54.100)
      avformat:                  YES (58.29.100)
      avutil:                    YES (56.31.100)
      swscale:                   YES (5.5.100)
      avresample:                YES (4.0.0)
    GStreamer:                   NO
    DirectShow:                  YES
    Media Foundation:            YES
      DXVA:                      YES

  Parallel framework:            Concurrency

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Intel IPP:                   2020.0.0 Gold [2020.0.0]
           at:                   C:/Users/user/OpenCV_CUDA/build/3rdparty/ippicv/ippicv_win/icv
    Intel IPP IW:                sources (2020.0.0)
              at:                C:/Users/user/OpenCV_CUDA/build/3rdparty/ippicv/ippicv_win/iw
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  NVIDIA CUDA:                   YES (ver 10.1, CUFFT CUBLAS FAST_MATH)
    NVIDIA GPU arch:             61
    NVIDIA PTX archs:

  cuDNN:                         YES (ver 8.0.3)

  OpenCL:                        YES (NVD3D11)
    Include path:                C:/Users/user/OpenCV_CUDA/opencv-4.4.0/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python (for build):            C:/Users/user/AppData/Local/Programs/Python/Python37/python.exe

  Java:
    ant:                         NO
    JNI:                         C:/Program Files/Java/jdk-12.0.1/include C:/Program Files/Java/jdk-12.0.1/include/win32 C:/Program Files/Java/jdk-12.0.1/include
    Java wrappers:               NO
    Java tests:                  NO

  Install to:                    C:/Users/user/OpenCV_CUDA/build/install
-----------------------------------------------------------------


OpenCL Platforms:
    NVIDIA CUDA
        dGPU: GeForce GTX 1060 (OpenCL 1.2 CUDA)
Current OpenCL device:
    Type = dGPU
    Name = GeForce GTX 1060
    Version = OpenCL 1.2 CUDA
    Driver version = 451.67
    Address bits = 64
    Compute units = 10
    Max work group size = 1024
    Local memory size = 48 KB
    Max memory allocation size = 768 MB
    Double support = Yes
    Host unified memory = No
    Device extensions:
        cl_khr_global_int32_base_atomics
        cl_khr_global_int32_extended_atomics
        cl_khr_local_int32_base_atomics
        cl_khr_local_int32_extended_atomics
        cl_khr_fp64
        cl_khr_byte_addressable_store
        cl_khr_icd
        cl_khr_gl_sharing
        cl_nv_compiler_options
        cl_nv_device_attribute_query
        cl_nv_pragma_unroll
        cl_nv_d3d10_sharing
        cl_khr_d3d10_sharing
        cl_nv_d3d11_sharing
        cl_nv_copy_opts
        cl_nv_create_buffer
        cl_khr_int64_base_atomics
        cl_khr_int64_extended_atomics
    Has AMD Blas = No
    Has AMD Fft = No
    Preferred vector width char = 1
    Preferred vector width short = 1
    Preferred vector width int = 1
    Preferred vector width long = 1
    Preferred vector width float = 1
    Preferred vector width double = 1
OpenCV's HW features list:
    ID=  1 (MMX) -> ON
    ID=  2 (SSE) -> ON
    ID=  3 (SSE2) -> ON
    ID=  4 (SSE3) -> ON
    ID=  5 (SSSE3) -> ON
    ID=  6 (SSE4.1) -> ON
    ID=  7 (SSE4.2) -> ON
    ID=  8 (POPCNT) -> ON
    ID=  9 (FP16) -> ON
    ID= 10 (AVX) -> ON
    ID= 11 (AVX2) -> ON
    ID= 12 (FMA3) -> ON
Total available: 12
Parallel framework: ms-concurrency (nthreads=12)