[英]Installing OPENCV with cmake failing. Python.h
當我嘗試在 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
首先,你需要運行
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())") ..
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.