【问题标题】:Building OpenCV cmake error: could NOT find PythonInterp构建 OpenCV cmake 错误:找不到 PythonInterp
【发布时间】:2016-04-21 22:09:02
【问题描述】:

为了构建 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,因此无法正确安装。

【问题讨论】:

  • 感谢您的编辑,b.enoit.be!

标签: python python-2.7 opencv numpy cmake


【解决方案1】:

您的错误是关于无法找到 numpy,因此请安装 numpy:

pip install numpy

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

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

然后,运行make clean,并删除您的/build 目录,然后运行您的cmake,然后再次运行make

【讨论】:

  • 你安装了numpy 吗?
  • 我不这么认为...我该怎么做?
  • pip install numpy,然后尝试重新编译opencv。
  • 谢谢!抱歉,如果这听起来很菜鸟,但我应该在我的主目录中运行它,对吗?
  • 不管你在哪里运行
【解决方案2】:

您可以手动指定每个 Python 版本的路径。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-30
    • 2016-04-06
    • 2015-11-04
    • 2013-05-25
    • 2015-06-17
    • 1970-01-01
    • 2018-03-12
    • 2020-11-02
    相关资源
    最近更新 更多