尝试在Mac上使用Python 3.5.1安装OpenCV 3.0时遇到问题。

错误如下。

有人可以帮我一点忙吗?

这是我的终端命令脚本:

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D PYTHON3_PACKAGES_PATH=~/.virtualenvs/cv3/lib/python3.5/site-packages \
    -D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5m.dylib \
    -D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/include/python3.5m \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D BUILD_EXAMPLES=ON \
    -D BUILD_opencv_python3=ON \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..

这是我得到的错误:
/Users/##/opencv/modules/python/src2/cv2.cpp:10:10: fatal error:
      'numpy/ndarrayobject.h' file not found
#include <numpy/ndarrayobject.h>
         ^
[ 73%] Linking CXX executable ../../bin/cpp-example-dft
[ 73%] Built target example_dft
Scanning dependencies of target example_distrans
[ 73%] Building CXX object samples/cpp/CMakeFiles/example_distrans.dir/distrans.cpp.o
[ 73%] Linking CXX executable ../../bin/cpp-example-detect_mser
[ 73%] Built target example_detect_mser
Scanning dependencies of target example_drawing
[ 73%] Building CXX object samples/cpp/CMakeFiles/example_drawing.dir/drawing.cpp.o
1 error generated.
make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1
make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 73%] Linking CXX executable ../../bin/cpp-example-distrans
[ 73%] Built target example_distrans
[ 73%] Linking CXX executable ../../bin/cpp-example-drawing
[ 73%] Built target example_drawing
[ 73%] Linking CXX shared library ../../lib/cv2.so
[ 73%] Built target opencv_python2
make: *** [all] Error 2

如果有人有任何指导或需要更多信息,请告诉我。

谢谢。

最佳答案

我可以使用conda在Mac上安装OpenCV 3:

conda install  -c https://conda.binstar.org/menpo opencv3

的Python:3.5.1

OpenCV的:3.0.0
>>> import cv2
>>> cv2.__version__
'3.0.0'

07-26 09:38
查看更多