gpt4 book ai didi

python - 构建 OpenCV cmake 错误 : could NOT find PythonInterp

转载 作者:太空宇宙 更新时间:2023-11-03 22:10:59 25 4
gpt4 key购买 nike

为了构建 OpenCV,我在我的 ~/opencv/build 目录中的终端中运行了这个:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/path/to/opencv-3.0.0/build -D PYTHON2_LIBRARY=/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin
-D PYTHON2_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Headers -D PYTHON2_PACKAGES_PATH=/usr/local/lib/python2.7/site-packages -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/path/to/opencv_contrib-3.0.0/modules ../

但无论发生什么,我都会在 Traceback 中看到这个错误:(Could NOT find PythonInterp:)

Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named numpy.distutils
-- Could NOT find PythonInterp: Found unsuitable version "2.7.11",
but required is at least "3.4" (found /usr/local/bin/python)
-- Could NOT find PythonInterp: Found unsuitable version "2.7.11",
but required is at least "3.2" (found /usr/local/bin/python)

再往下看,这会出现

-- 
-- Python 2:
-- Interpreter: /usr/local/bin/python2.7 (ver 2.7.11)
--
-- Python 3:
-- Interpreter: NO
--
-- Python (for build): /usr/local/bin/python2.7
--
-- Java:
-- ant: NO
-- JNI:

正确的输出应该是这样的: correct Python Interp output

我已经尝试了所有方法,但是这个问题不断出现!本质上,我无法正确构建 OpenCV,因此无法正确安装它。

最佳答案

你的错误是关于找不到 numpy,所以安装 numpy:

pip install numpy

此外,更改您的包含目录以确保您确实包含了它。对于 PYTHON2_INCLUDE_DIR:

-D PYTHON2_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Headers

然后,运行make clean,删除你的/build目录,然后运行你的cmake,然后是make 再次。

关于python - 构建 OpenCV cmake 错误 : could NOT find PythonInterp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36781326/

25 4 0
文章推荐: html - 如何仅向div的背景图像添加模糊效果?
文章推荐: c# - 付款成功,我们的数据与查询字符串数据相匹配,但无论如何都变成了 INVALID!
文章推荐: html - 使用 HTML
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com