
[ 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 directorycompilation terminated.
我有opencv和opencv-contrib通过使用git checkout 3.1.0克隆版本3.1.0并且我正在尝试构建〜/ Soft / opencv / build,其中我在〜/ Soft / opencv-contrib中有opencv-contrib .我正在使用i7-4960X运行Ubuntu GNOME 15.10.
我的主要目标是在我的anaconda3安装中使opencv工作,所以我的cmake命令如下:
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 ..
我的cmake命令的输出在这里:http://pastebin.com/qtd1wyMb – 就我所见,一切都还可以.
然后我运行make -j12来安装opencv并在几次警告之后运行正常,直到94%,我得到以下输出:
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 directorycompilation terminated.modules/python3/CMakefiles/opencv_python3.dir/build.make:278: recipe for target 'modules/python3/CMakefiles/opencv_python3.dir/__/src2/cv2.cpp.o' Failedmake[2]: *** [modules/python3/CMakefiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1CMakefiles/Makefile2:18929: recipe for target 'modules/python3/CMakefiles/opencv_python3.dir/all' Failedmake[1]: *** [modules/python3/CMakefiles/opencv_python3.dir/all] Error 2make[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.oBuilding 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.oBuilding 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.olinking CXX executable ../../bin/cpp-example-bgfg_segmlinking 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_trackingBuilding 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_autofocusBuilding 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.oBuilding 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.olinking 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_3calibrationlinking CXX executable ../../bin/opencv_test_stitching[ 94%] Built target opencv_test_stitchinglinking CXX executable ../../bin/cpp-tutorial-pnp_registration[ 94%] Built target cpp-tutorial-pnp_registrationlinking CXX executable ../../bin/cpp-tutorial-pnp_detection[ 94%] Built target cpp-tutorial-pnp_detectionlinking CXX executable ../../bin/opencv_perf_stitching[ 94%] Built target opencv_perf_stitchingMakefile:146: recipe for target 'all' Failedmake: *** [all] Error 2
make的完整输出在此供参考:http://pastebin.com/1zNgsckZ
看起来我的问题是因为我使用anaconda3路径而不是标准的python3路径,它再也找不到Python.h了.但是,当我使用系统python3安装安装时,我无法将opencv导入我需要它的anaconda.
我安装了python3-dev和python-dev,所以Python.h应该在我的机器上.为了使openCV找到Python.h,我需要更改什么?
编辑:我发现Anaconda3的Python.h在anaconda3 / include / python3.5m /所以我设置python3_INCLUDE_DIR = anaconda3 / include / python3.5m /现在我得到一个不同的错误:
Scanning dependencIEs of target opencv_python3linking CXX executable ../../bin/opencv_test_optflow[ 91%] Building CXX object modules/python3/CMakefiles/opencv_python3.dir/__/src2/cv2.cpp.oIn 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 directorycompilation terminated.modules/python3/CMakefiles/opencv_python3.dir/build.make:278: recipe for target 'modules/python3/CMakefiles/opencv_python3.dir/__/src2/cv2.cpp.o' Failedmake[2]: *** [modules/python3/CMakefiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1CMakefiles/Makefile2:18929: recipe for target 'modules/python3/CMakefiles/opencv_python3.dir/all' Failedmake[1]: *** [modules/python3/CMakefiles/opencv_python3.dir/all] Error 2make[1]: *** Waiting for unfinished jobs....解决方法 我解决了这个问题.问题是python3_INCLUDE_DIR设置为〜/ anaconda3 / include而Anaconda的Python.h实际上位于〜/ anaconda3 / include / python3.5m内.设置python3_INCLUDE_DIR = anaconda3 / include / python3.5m /修复此问题,因为它现在看到Python.h
但是,这导致了另一个问题,其中某些.h文件如hdf5.h和H5public.h对OpenCV不再可见,因为它们位于主要的anaconda3 / include /目录中,而不是在子文件夹中.
解决方法是将include /目录中的所有.h文件复制到include / python3.5m目录中(将两者的内容复制到另一个目录中并将其设置为路径也可以工作)以便所有.h文件位于编译器可见的同一文件夹中. OpenCV现在正在构建!
总结以上是内存溢出为你收集整理的在anaconda3中安装openCV – Python.h:没有这样的文件或目录全部内容,希望文章能够帮你解决在anaconda3中安装openCV – Python.h:没有这样的文件或目录所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)