【问题标题】:How do I install OpenCV for Python 3.4?如何为 Python 3.4 安装 OpenCV?
【发布时间】:2015-04-05 23:07:40
【问题描述】:

我通过 Anaconda 发行版使用 Python 3.4。他们似乎没有针对 OpenCV 的 Python 3.4 绑定。我尝试从源代码使用 Cmake,但无济于事。 谁能帮我为 Python 3.4.x 安装 OpenCV?

【问题讨论】:

  • 您尝试编译时发生了什么?
  • 当我运行 CMake 实用程序时,我收到一条错误消息,提示 OpenCV/source 文件夹中的 CMakelists.txt 文件中缺少某些内容?
  • 嗨,我开始为 Python 3.x 编译和生成构建。但我不知道如何从这里开始。如何让 cv2 模块在 Python 3.x 中工作
  • 我使用的是 64 位的 Windows 7。提供的解决方案适用于 Linux 和 OS X。

标签: python opencv


【解决方案1】:
conda install -c menpo opencv3

成功了。但是你必须安装 anaconda。

【讨论】:

    【解决方案2】:

    有很多关于这个的教程和问题(关于 SO)。

    This 似乎回答了你的问题。 编辑:转载如下:

    1)  Download OpenCV from http://opencv.org/downloads.html and extract
    
    2)From the extracted folder, copy the file from the extracted directory:   
    opencv/build/python/2.7/(either x86 or x64, depending on your Anaconda 
    version)/cv2.pyd to your Anaconda site-packages directory, e.g., 
    C:\Anaconda\Lib\site-packages
    
    3)To get ffmpeg within opencv to work, you'll have to add the directory 
    that ffmpeg is located in to the path (e.g., opencv/sources/3rdparty
    /ffmpeg). Then you'll have to find the dll in that folder (e.g., 
    opencv_ffmpeg_64.dll) and copy or rename it to a filename that includes 
    the opencv version you are installing, (e.g., opencv_ffmpeg249_64) for 
    2.4.9.
    

    {结束复制}

    EDIT2:OpenCV 不支持 Python 3.x,OpenCV 3.0 版除外(仍处于试验阶段,处于测试阶段)。从下载站点下载 3.0 版本并尝试一下。(感谢this question)。

    A SO question with a possible tip, if the previous doesn't work.

    最后,我将向您指出如何安装它的read the docs tutorial

    祝你好运!

    【讨论】:

    • 我对这个网站了解不多。如果兼容的二进制文件尚不可用,您能否告诉我如何从源代码安装?
    • 是的,我这样做了,但在 Python-3.4 中出现以下错误:ImportError: DLL load failed: The specified module could not be found.
    • Python 2.7下的cv2.pyd与Python 3.4不兼容
    • 我安装了OpenCV 3.0 beta,仍然报同样的错误:ImportError: DLL load failed: The specified module could not be found.
    • 嗨,我使用 CMake 和 MingW 为 Python 3.4 构建了 OpenCV。它构建成功,但我不知道从这里做什么。如何在 Python 的 lib/site-packages 文件夹中获取 OpenCV 模块?导入 cv2 不起作用。任何帮助将不胜感激。
    【解决方案3】:

    这个方法很简单:

    我建议通过 anaconda 使用。

    在anaconda中创建环境(推荐一个): conda create -n deeplearning

    然后,通过以下方式激活:activate deeplearning

    现在,为 Anaconda3 的 python3.x 安装 opencv:

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

      这将在该环境中简单地安装 opencv3 和其他相关库:spicy、numpy、scikit-learn 和 matplotlib。

    检查Opencv是否安装为:

    >>> import cv2
    >>> cv2.__version__
    '3.1.0'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-09
      • 2015-10-24
      • 1970-01-01
      • 1970-01-01
      • 2011-03-20
      • 2018-08-26
      • 1970-01-01
      • 2016-06-26
      相关资源
      最近更新 更多