0
votes

When i try to make in opencv/build/ as this guide tells me: 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 Config 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

1
what is the output of python3.7-config?jmunsch
Where is it located?Oscar
it's part of the python install it's a cli program that you can execute. it should show you where the include directory is for python.jmunsch
Ill checke og:)Oscar
I have changed the PYTHON3_INCLUDE_DIR = to the ouput of python3-config --includesOscar

1 Answers

0
votes

First, you need to run

sudo apt-get install python3-dev (or python3.x-dev according to your version)

Then here is the command I ran successfully:

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())") ..