2016-04-23 2 views
6

Ich versuche opencv 3.1.0 für meine anaconda3 Installation zu bauen und meine Build versagt bei:OpenCV in anaconda3 Installation - Python.h: Keine solche Datei oder das Verzeichnis

[ 94%] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o 
/home/mikel/Soft/opencv/modules/python/src2/cv2.cpp:6:20: fatal error: Python.h: No such file or directory 
compilation terminated. 

Ich habe opencv und opencv -contrib mit Versionen geklonte 3.1.0 von git checkout 3.1.0 in beide mit und ich versuche, in ~/Soft/opencv/build zu bauen, wo ich opencv-contrib in ~/Soft/opencv-contrib habe. Ich benutze Ubuntu GNOME 15.10 mit einem i7-4960X.

Mein Hauptziel ist es, opencv Arbeit in meinem anaconda3 Installation zu machen und so mein Cmake Befehl ist folgende:

cmake \ 
-D CMAKE_BUILD_TYPE=RELEASE \ 
-D CMAKE_INSTALL_PREFIX=/usr/local \ 
-D INSTALL_C_EXAMPLES=OFF \ 
-D INSTALL_PYTHON_EXAMPLES=ON \ 
-D OPENCV_EXTRA_MODULES_PATH=~/Soft/opencv_contrib/modules \ 
-D PYTHON3_EXECUTABLE=/home/mikel/anaconda3/bin/python3.5 \ 
-D PYTHON3_INCLUDE_DIR=/home/mikel/anaconda3/include/ \ 
-D PYTHON3_LIBRARY=/home/mikel/anaconda3/lib/libpython3.5m.so \ 
-D PYTHON3_PACKAGES_PATH=/home/mikel/anaconda3/lib/python3.5/site-packages/ \ 
-D PYTHON3_NUMPY_INCLUDE_DIRS=/home/mikel/anaconda3/lib/python3.5/site-packages/numpy/core/include \ 
-D PYTHON_DEFAULT_AVAILABLE=/home/mikel/anaconda3/bin/python3.5 \ 
-D BUILD_EXAMPLES=ON .. 

Der Ausgang meines Cmake Befehl ist hier: http://pastebin.com/qtd1wyMb - Alles in Ordnung so weit wie möglich sehen.

ich dann make -j12 laufen opencv zu installieren und nach ein paar Warnungen läuft es bis 94% in Ordnung, wo ich die folgende Ausgabe:

Scanning dependencies of target opencv_python3 
[ 94%] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o 
/home/mikel/Soft/opencv/modules/python/src2/cv2.cpp:6:20: fatal error: Python.h: No such file or directory 
compilation terminated. 
modules/python3/CMakeFiles/opencv_python3.dir/build.make:278: recipe for target 'modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o' failed 
make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1 
CMakeFiles/Makefile2:18929: recipe for target 'modules/python3/CMakeFiles/opencv_python3.dir/all' failed 
make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2 
make[1]: *** Waiting for unfinished jobs.... 
[ 94%] Building CXX object modules/stitching/CMakeFiles/opencv_perf_stitching.dir/perf/perf_main.cpp.o 
[ 94%] Built target opencv_test_optflow 
[ 94%] [ 94%] Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_registration.dir/tutorial_code/calib3d/real_time_pose_estimation/src/CsvWriter.cpp.o 
Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_detection.dir/tutorial_code/calib3d/real_time_pose_estimation/src/CsvReader.cpp.o 
[ 94%] [ 94%] Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_registration.dir/tutorial_code/calib3d/real_time_pose_estimation/src/ModelRegistration.cpp.o 
Building CXX object modules/stitching/CMakeFiles/opencv_test_stitching.dir/test/ocl/test_warpers.cpp.o 
[ 94%] Building CXX object modules/stitching/CMakeFiles/opencv_perf_stitching.dir/perf/opencl/perf_stitch.cpp.o 
Linking CXX executable ../../bin/cpp-example-bgfg_segm 
Linking CXX executable ../../bin/cpp-example-autofocus 
[ 94%] Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_detection.dir/tutorial_code/calib3d/real_time_pose_estimation/src/CsvWriter.cpp.o 
[ 94%] Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_detection.dir/tutorial_code/calib3d/real_time_pose_estimation/src/ModelRegistration.cpp.o 
[ 94%] Linking CXX executable ../../bin/opencv_test_tracking 
Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_registration.dir/tutorial_code/calib3d/real_time_pose_estimation/src/Mesh.cpp.o 
[ 94%] Built target example_bgfg_segm 
[ 94%] [ 94%] Built target example_autofocus 
Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_registration.dir/tutorial_code/calib3d/real_time_pose_estimation/src/Model.cpp.o 
[ 94%] [ 94%] Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_registration.dir/tutorial_code/calib3d/real_time_pose_estimation/src/Utils.cpp.o 
Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_registration.dir/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.cpp.o 
[ 94%] Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_detection.dir/tutorial_code/calib3d/real_time_pose_estimation/src/Mesh.cpp.o 
[ 94%] Built target opencv_test_tracking 
[ 94%] Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_detection.dir/tutorial_code/calib3d/real_time_pose_estimation/src/Model.cpp.o 
[ 94%] Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_detection.dir/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.cpp.o 
[ 94%] Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_detection.dir/tutorial_code/calib3d/real_time_pose_estimation/src/Utils.cpp.o 
[ 94%] Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_registration.dir/tutorial_code/calib3d/real_time_pose_estimation/src/RobustMatcher.cpp.o 
[ 94%] Building CXX object samples/cpp/CMakeFiles/cpp-tutorial-pnp_detection.dir/tutorial_code/calib3d/real_time_pose_estimation/src/RobustMatcher.cpp.o 
[ 94%] Building CXX object modules/stitching/CMakeFiles/opencv_perf_stitching.dir/perf/opencl/perf_warpers.cpp.o 
Linking CXX executable ../../bin/cpp-example-3calibration 
[ 94%] Building CXX object modules/stitching/CMakeFiles/opencv_test_stitching.dir/test/test_main.cpp.o 
[ 94%] Built target example_3calibration 
Linking CXX executable ../../bin/opencv_test_stitching 
[ 94%] Built target opencv_test_stitching 
Linking CXX executable ../../bin/cpp-tutorial-pnp_registration 
[ 94%] Built target cpp-tutorial-pnp_registration 
Linking CXX executable ../../bin/cpp-tutorial-pnp_detection 
[ 94%] Built target cpp-tutorial-pnp_detection 
Linking CXX executable ../../bin/opencv_perf_stitching 
[ 94%] Built target opencv_perf_stitching 
Makefile:146: recipe for target 'all' failed 
make: *** [all] Error 2 

Die vollständige Ausgabe von make ist hier als Referenz: http://pastebin.com/1zNgsckZ

es sieht aus wie mein Problem ist, weil ich die anaconda3 Pfade anstelle der Standard python3 Pfade bin mit, kann es nicht mehr Python.h finden. Allerdings, wenn ich das System python3 Installation Installation verwenden, kann ich nicht opencv in anaconda importieren, wo ich es brauche.

Ich habe python3-dev und Python-dev installiert, so Python.h auf meiner Maschine sein sollte. Was muss ich ändern, damit openCV Python.h findet?

EDIT: Ich fand, dass Anaconda3 der Python.h in anaconda3 ist/include/python3.5m/so ich gesetzt PYTHON3_INCLUDE_DIR=anaconda3/include/python3.5m/ und jetzt bekomme ich einen anderen Fehler:

Scanning dependencies of target opencv_python3 
Linking CXX executable ../../bin/opencv_test_optflow 
[ 91%] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o 
In file included from /home/mikel/Soft/opencv/build/modules/python3/pyopencv_generated_include.h:11:0, 
       from /home/mikel/Soft/opencv/modules/python/src2/cv2.cpp:12: 
/home/mikel/Soft/opencv_contrib/modules/hdf/include/opencv2/hdf/hdf5.hpp:40:18: fatal error: hdf5.h: No such file or directory 
compilation terminated. 
modules/python3/CMakeFiles/opencv_python3.dir/build.make:278: recipe for target 'modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o' failed 
make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1 
CMakeFiles/Makefile2:18929: recipe for target 'modules/python3/CMakeFiles/opencv_python3.dir/all' failed 
make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2 
make[1]: *** Waiting for unfinished jobs.... 

Antwort

8

ich das Problem behoben. Das Problem war, dass PYTHON3_INCLUDE_DIR-~/anaconda3/include gesetzt wurde, während Anacondaâs Python.h tatsächlich in ~/anaconda3/include/python3.5m ist. Einstellen PYTHON3_INCLUDE_DIR=anaconda3/include/python3.5m/ behebt dieses Problem, wie es jetzt sieht Python.h

Dies ist jedoch zu einem anderen Problem geführt, dass einige .h Dateien wie hdf5.h und H5public.h nicht mehr zu OpenCV sichtbar waren, da diese in der Haupt anaconda3 waren/include/Verzeichnis , nicht im Unterordner.

Die Lösung hierfür war, alle H-Dateien aus dem include/ Verzeichnis in das Verzeichnis include/python3.5m(Kopieren der Inhalte sowohl in ein anderes Verzeichnis und auch arbeiten Einstellung, die als Pfad würde) zu kopieren, so dass alle. h-Dateien befinden sich im selben Ordner, der für den Compiler sichtbar ist. OpenCV baut jetzt!