我试图通过Anaconda为Python安装OpenCV,但我似乎无法解决这个问题。

我试着

conda install opencv
conda install cv2

我也试着搜索

conda search cv

没有雪茄。我无意中看到这个列出了opencv作为一个包含包:

http://docs.continuum.io/anaconda/pkgs.html

在运行conda info后,我注意到我的版本是3.4.1,但我似乎在网上找不到任何关于这个版本的信息。我对此很困惑。

我是不是遗漏了一些很明显的东西?如果opencv可用于Anaconda的以前版本,那么为什么它不能用于新版本呢?为什么这个链接只显示版本1.9.2的文档?


当前回答

它在anaconda3 windows 10上工作,我已经在2019年12月5日下载了它。

首先,使用这个命令:

PIP安装opencv-contrib-python

之后,Windows将请求许可并重试:

PIP安装opencv-contrib-python——user

看看这个,它工作了!!

其他回答

它在anaconda3 windows 10上工作,我已经在2019年12月5日下载了它。

首先,使用这个命令:

PIP安装opencv-contrib-python

之后,Windows将请求许可并重试:

PIP安装opencv-contrib-python——user

看看这个,它工作了!!

下面是使用conda安装适用于Python的包的一般方法:

conda search packageName e.g. conda search opencv If this doesn't return results, conda install packageName will not work. At this point you can go to, https://anaconda.org/ and type the packageName into the search box. If this pulls up results (which it should for OpenCV), then click on one of the results that is for your platform (e.g. win-64). The next page will show you the command to use to install this package (e.g. conda install -c menpo opencv=2.4.11). If your package doesn't return results by search https://anaconda.org, then you can try pip install packageName.

注意:当我使用步骤3为win-64安装OpenCV时,当我试图导入cv2时,我得到了一个错误。

错误如下:

RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
File "<stdin>", line 1, in <module>

ImportError: numpy.core.multiarray导入失败

我认为这个错误是由于软件包版本冲突。尽管如此,这是安装OpenCV和其他Python包的有效方法,只是可能需要解决一些包的版本冲突。

我在MAC机上的一个水蟒虚拟环境。对我来说,

conda install -c conda-forge opencv

工作得很好。

它安装了opencv 3.4.4版

希望能有所帮助。

在Anaconda窗口中安装当前版本OpenCV 3.3的正确命令:

conda install -c conda-forge opencv

or

conda install -c conda-forge/label/broken opencv

3.2使用这个:

conda install -c menpo opencv3

虽然不是通过Conda,这是Ubuntu特有的,安装OpenCV的所有贡献模块,如SIFT和SURF,最简单的方法是使用:

PIP安装opencv-contrib-python

它支持Python2.7+和Python 3.4+

如果你选择不内置contribs,你可以这样做:

PIP安装opencv-python

在运行这些命令之前,你需要安装以下依赖项:

Sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

这是一个关于在Ubuntu上设置OpenCV的好教程: https://medium.com/@debugvn/installing-opencv-3-3-0-on-ubuntu-16-04-lts-7db376f93961