Python 3 & Anaconda

asked 2015-08-25 06:33:50 -0500

peter_cz gravatar image

updated 2015-09-16 02:36:42 -0500


I am starting with OpenCV and building latest OpenCV using MSVC++ 2015, Anacodna 3 (as python distribution). Using CMake for configuring and I am getting

... Found PythonInterp: C:/Anaconda3/python.exe (found suitable version "3.4.3", minimum required is "3.4") Could NOT find PythonLibs: Found unsuitable version "2.7.10+", but required is exact version "3.4.3" (found PYTHON_LIBRARY-NOTFOUND) ....

I have python 2.7.10 as well installed - how to tell CMake for correct config or what to modify or what missing for PythonLibs?

Thank you very much for your help.

Thank you, Best regards


P.S. comment on 9/16/2015

I'm using Anaconda3 x86 distribution and I did configure OpenCV as

  Python 2:
    Interpreter:                 C:/Anaconda2_x86/python.exe (ver 2.7.10)

  Python 3:
    Interpreter:                 C:/Anaconda3_x86/python.exe (ver 3.4.3)
    Libraries:                   C:/Anaconda3_x86/libs/python34.lib (ver 3.4.3)
    numpy:                       C:/Anaconda3_x86/lib/site-packages/numpy/core/include (ver 1.9.2)
    packages path:               C:/Anaconda3_x86/Lib/site-packages

  Python (for build):            C:/Anaconda2_x86/python.exe

How to tell OpenCV (CMake configuration) to use C:/Anaconda3_x86/python.exe (ver 3.4.3) for build?

Now by compiling for python 3 I got stop saying:

Scanning dependencies of target opencv_python3
[ 76%] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.obj
In file included from C:/Anaconda3_x86/include/Python.h:8:0,
                 from C:\Data\Projects\Vision_iMX\vision_sdk\opencv\modules\python\src2\cv2.cpp:6:
C:/Anaconda3_x86/include/pyconfig.h:440:5: warning: "_MSC_VER" is not defined [-Wundef]
 #if _MSC_VER >= 1800
[ 76%] Linking CXX shared library ..\..\lib\cv2.pyd
CMakeFiles\opencv_python3.dir/objects.a(cv2.cpp.obj):cv2.cpp:(.text$_ZL8failmsgpPKcz+0x40): undefined reference to `_imp__PyExc_TypeE
CMakeFiles\opencv_python3.dir/objects.a(cv2.cpp.obj):cv2.cpp:(.text$_ZL7failmsgPKcz+0x40): undefined reference to `_imp__PyExc_TypeEr
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: CMakeFiles\opencv_python3.dir/objects.a(cv2.cpp.obj): bad reloc
collect2.exe: error: ld returned 1 exit status
modules\python3\CMakeFiles\opencv_python3.dir\build.make:224: recipe for target 'lib/cv2.pyd' failed
mingw32-make[2]: *** [lib/cv2.pyd] Error 1
CMakeFiles\Makefile2:7494: recipe for target 'modules/python3/CMakeFiles/opencv_python3.dir/all' failed
mingw32-make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
Makefile:148: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

Do you have any experience on compiling OpenCV for python3 or how to resolve it?

Bets regards, Peter

edit retag flag offensive close merge delete


imho, you cut the error msg a bit too short. can we have some more lines before and after that ?

cmake first tries to find a python 3 environment, after that a 2.7 one. it looks like your opencv3 anaconda does not come with dev libs and headers, but hard to see from your snippet (again, too short)

berak gravatar imageberak ( 2015-08-25 07:00:20 -0500 )edit

what exactly and how to include those dev python libs & headers?

peter_cz gravatar imagepeter_cz ( 2015-09-16 02:22:00 -0500 )edit