Ask Your Question

Revision history [back]

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

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/tutorial_py_setup_in_windows.html. 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 . Actually, I used command "conda list" in DOS, and there wasn't opencv.

What 's wrong with that? What should I do next to finish install?

image description

image description(/upfiles/15173301268033749.png)

click to hide/show revision 2
None

updated 2018-01-30 10:55:45 -0600

berak gravatar image

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

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/tutorial_py_setup_in_windows.html. 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 . Actually, I used command "conda list" in DOS, and there wasn't opencv.

What 's wrong with that? What should I do next to finish install?

image description

image description(/upfiles/15173301268033749.png)

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

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/tutorial_py_setup_in_windows.html. 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" conda list in DOS, and there wasn't opencv.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 /wd4589 /MP8  /MDd /Zi /Ob0 /Od /RTC1 
    C Compiler:                  D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/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        /MP8  /MD /O2 /Ob2 /DNDEBUG  /Zi
    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        /MP8  /MDd /Zi /Ob0 /Od /RTC1 
    Linker flags (Release):      /machine:x64  /INCREMENTAL:NO  /debug
    Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL 
    ccache:                      NO
    Precompiled headers:         YES
    Extra dependencies:
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 calib3d core dnn features2d flann highgui imgcodecs imgproc ml objdetect photo python3 python_bindings_generator shape stitching superres ts video videoio videostab
    Disabled:                    js world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 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 (ver 90)
    WEBP:                        build (ver encoder: 0x020e)
    PNG:                         build (ver 1.6.34)
    TIFF:                        build (ver 42 - 4.0.9)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)

  Video I/O:
    Video for Windows:           YES
    DC1394:                      NO
    FFMPEG:                      YES (prebuilt binaries)
      avcodec:                   YES (ver 57.89.100)
      avformat:                  YES (ver 57.71.100)
      avutil:                    YES (ver 55.58.100)
      swscale:                   YES (ver 4.6.100)
      avresample:                YES (ver 3.5.0)
    GStreamer:                   NO
    DirectShow:                  YES

  Parallel framework:            Concurrency

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Intel IPP:                   2017.0.3 [2017.0.3]
           at:                   D:/software/openCV/opencv_build_from_source/build_final2/3rdparty/ippicv/ippicv_win
    Intel IPP IW:                sources (2017.0.3)
              at:                D:/software/openCV/opencv_build_from_source/build_final2/3rdparty/ippicv/ippiw_win
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO

  NVIDIA CUDA:                   NO

  OpenCL:                        YES (no extra features)
    Include path:                D:/software/openCV/opencv_build_from_source/source/opencv/sources/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  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

  Python (for build):            D:/software/Anaconda3/install_path/envs/cntk-py36/python.exe
    Pylint:                      D:/software/Anaconda3/install_path/Scripts/pylint.exe (ver: 1.7.2, checks: 113)

  Java:
    ant:                         NO
    JNI:                         D:/Program Files (x86)/Java/jdk1.8.0_144/include D:/Program Files (x86)/Java/jdk1.8.0_144/include/win32 D:/Program Files (x86)/Java/jdk1.8.0_144/include
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        NO

  Install to:                    D:/software/openCV/opencv_build_from_source/build_final2/install
-----------------------------------------------------------------

Configuring done
Generating done

I found there was cv2.cp36-win_amd64.pyd generated in my {python}\Lib\site-packages. I have tried to open it with python cv2.cp36-win_amd64.pyd but what I got are File "cv2.cp36-win_amd64.pyd", line 1 SyntaxError: Non-UTF-8 code starting with '\x90' in file cv2.cp36-win_amd64.pyd on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

What 's wrong with that? What should I do next to finish install?