当我尝试在opencv / build /中make
时,如本指南所述:https://intelligentbee.com/2015/11/18/build-a-face-detector-on-os-x-using-opencv-and-c/
/Users/oscarlajgaard/opencv-3.3.1/modules/python/src2/cv2.cpp:6:10: fatal error:
'Python.h' file not found
#include <Python.h>
^~~~~~~~~~
CMAKE配置PYTHON3
PYTHON3_EXECUTABLE = / usr / local / bin / python3
PYTHON3_INCLUDE_DIR = /usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m /
PYTHON3_LIBRARY = /usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7.dylib
答案 0 :(得分:0)
首先,您需要运行
sudo apt-get install python3-dev (or python3.x-dev according to your version)
然后这是我成功运行的命令:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D BUILD_opencv_python3=ON \
-D HAVE_opencv_python3=ON \
-D PYTHON_DEFAULT_EXECUTABLE=$(which python3) \
-D PYTHON_EXECUTABLE=$(which python3) \
-D BUILD_opencv_python2=OFF \
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D PYTHON3_INCLUDE_DIRS=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")\
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") ..