after "17. right-click on INSTALL and build it" successfully, I still can't import cv2

asked 2018-01-30 10:47:40 -0600

ambitiouszty gravatar image

updated 2018-01-30 19:33:33 -0600

I use window 10 x64 , python 3.6.2, Microsoft Visual Studio community 2017, cmake 3.10.0

I want to Building OpenCV from source with extra modules. So I follow the tutorial from https://docs.opencv.org/master/d5/de5.... after " Cmake" and generating .sln, I open the .sln with Microsoft Visual Studio community 2017. I built "ALL_BUILD" and "INSTALL" successfully, but still can't import the cv2 .

>>> import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: DLL load failed: 找不到指定的模块。

Actually, I used command conda list in DOS, and there wasn't opencv. the Cmake output are as follow:

     Selecting Windows SDK version 10.0.15063.0 to target Windows 10.0.16299.
    Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.7")
    Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.6")
    found Intel IPP (ICV version): 2017.0.3 [2017.0.3]
    at: D:/software/openCV/opencv_build_from_source/build_final2/3rdparty/ippicv/ippicv_win
    found Intel IPP IW sources: 2017.0.3
    at: D:/software/openCV/opencv_build_from_source/build_final2/3rdparty/ippicv/ippiw_win
    Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
    Could not find 

OpenBLAS lib. Turning OpenBLAS_FOUND off
A library with BLAS API not found. Please specify library location.
LAPACK requires BLAS
A library with LAPACK API not found. Please specify library location.
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
Could NOT find Matlab (missing: MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) 
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
Excluding from source files list: D:/software/openCV/opencv_build_from_source/build_final2/modules/imgproc/accum.neon.cpp
Pylint: registered 113 targets. Build 'check_pylint' target to run checks ("cmake --build . --target check_pylint" or "make check_pylint")

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

  Platform:
    Timestamp:                   2018-01-30T15:53:30Z
    Host:                        Windows 10.0.16299 AMD64
    CMake:                       3.10.0-rc4
    CMake generator:             Visual Studio 15 2017 Win64
    CMake build tool:            D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/MSBuild.exe
    MSVC:                        1911

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2
      SSE4_1 (3 files):          + SSSE3 SSE4_1
      SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (2 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (9 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2

  C/C++:
    Built as dynamic libs?:      YES
    C++11:                       YES
    C++ Compiler:                D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/x64/cl.exe  (ver 19.11.25508.2)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR  /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi      /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP8  /MD /O2 /Ob2 /DNDEBUG  /Zi
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR  /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi      /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 ...
(more)
edit retag flag offensive close merge delete

Comments

i removed your useless screenshots. please edit your question again, and add text versions of whatever you think is nessecary. most importantly - we need to see the cmake output, too !

berak gravatar imageberak ( 2018-01-30 10:57:11 -0600 )edit
  • python cv2.cp36-win_amd64.pyd -- that's the wrong command, it is not a python script. instead start python without anything else, and then import cv2

  • you seem to have 2 pythons on your machine, and it is taking the libs from C:/Program Files/Python36/libs/python36.lib but anything else from D:/software/Anaconda3/install_path/envs/cntk-py36 . that's bad.

  • most likely, it will install it here: D:/software/Anaconda3/install_path/envs/cntk-py36/Lib/site-packages , so make sure, you're calling the correct python.exe (also from there !)

berak gravatar imageberak ( 2018-01-31 08:10:23 -0600 )edit

thank you. I have 2 pythons, they both are python 3.6.2 and controled by anconda.

I tried it again and payed more attention to what you said. Something interesting is that I add D:/software/Anaconda3/install_path/envs/cntk-py36/libs/python36.lib to PYTHON3_LIBRARY, but after clicking on configure button, what I got is still Python 3: Interpreter: D:/software/Anaconda3/install_path/envs/cntk-py36/python.exe (ver 3.6.2) Libraries: **C:/Program Files/Python36/libs/python36.lib (ver 3.6.2)** numpy: D:/software/Anaconda3/install_path/envs/cntk-py36/Lib/site-packages/numpy/core/include (ver ) packages path: D:/software/Anaconda3/install_path/envs/cntk-py36/Lib/site-packages. what should I do?

ambitiouszty gravatar imageambitiouszty ( 2018-01-31 09:20:08 -0600 )edit

I rewrited the CMakeCache.txt . Now the second problem you listed are overcomed but import cv2 still doesn't work. ImportError: DLL load failed: 找不到指定的模块。 After right clickinng ALL_BUILD and build it, I right click INSTALL and build it. They both are finished without error. However, what I got are D:/software/Anaconda3/install_path/envs/cntk-py36/Lib/site-packages/cv2.cp36-win_amd64.pyd . what should I do next? someone told me there are severial setting process before right clicking ALL_BUILD. Is that true?

ambitiouszty gravatar imageambitiouszty ( 2018-01-31 20:21:36 -0600 )edit