how to build opencv for python3 when both python2 and python3 are installed

前端 未结 5 2095
我在风中等你
我在风中等你 2020-12-13 10:29

I was trying to build opencv for python3. However, cmake always sets python build option to be python2.7.11 even after I manually specified include and lib option for python

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 11:06

    I was struggling with this one for some hours and the answers mentioned above didn't solve the problem straightaway.

    Adding to Ivan's answer, I had to include these flags in cmake to make this work:

    -D BUILD_NEW_PYTHON_SUPPORT=ON \
    -D BUILD_opencv_python3=ON \
    -D HAVE_opencv_python3=ON \
    -D PYTHON_DEFAULT_EXECUTABLE= 
    

    I leave that here, so it is maybe useful for someone else in the future.

提交回复
热议问题