我试图通过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的文档?


当前回答

Windows专用解决方案。OpenCV 3。为Python 3.x安装pip

下载.whl文件(cpMN,其中有Python M.N)。contrib包含opencv额外包。例如,假设你有Python 3.6和Windows 64位,你可以下载opencv_python - 3.2.0+contrib - cp36 - cp36m - win_amd64.whl

从命令提示符类型:

pip install opencv_python‑3.2.0+contrib‑cp36‑cp36m‑win_amd64.whl

你的conda列表中会有一个包:opencv-python 3.2.0+contrib <pip>

现在你可以测试它(没有错误):

>>> import cv2
>>>

原始的源代码页面,我采取的信息是在这里。

其他回答

我有步骤在回购,将帮助您正确安装OpenCV。

如果链接断了,看这个。

对于要求和先决条件,请遵循以下说明:

你需要有WINDOWS操作系统来开始这个项目。

Windows 7到10

请仔细执行以下步骤

Install Anaconda2 32/64 python 2 or Install Anaconda3 32/64 python 3 It Depends on System Information Along the way you must check all the options ignore the red text Then wait till installation completed ... Open CMD admin when finish installed Make sure that the anaconda-python is configured in CMD admin Type: python This will come out: C:\WINDOWS\system32>python Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. Next is to install packages: Numpy OpenCV PyMySQL or pymysql Install and Import OpenCV conda install -c conda-forge opencv = (version optional) (click yes if there's updates) Install and Import Numpy pip install numpy (click yes if there's updates) Install and Import PyMySQL/pymysql pip install PyMySQL or pymysql When all the package is completely installed, then you must Reboot it. go to CMD admin again type "python" import cv2 (cv2 is OpenCV) import Numpy or numpy import pymysql import os from PIL from Image if all of then is ok.. your ready to run the code!! After you finish all the steps, you can now test the code in SPYDER python that I use

我也遇到过同样的问题,但我现在已经解决了。这就是我所做的:

首先在命令提示符中输入conda install -c https://conda.binstar.org/menpo opencv,然后找到路径Anaconda\pkgs\opencv-2.4.9.1-np19py27_0\Lib\site-packages。现在将这里的所有文件复制到Anaconda\Lib\site-packages中。现在你可以在Python中使用OpenCV了。

我在命令提示符中输入了如下命令:

conda install -c menpo opencv=2.4.11

这对我很管用!!

我刚刚在Windows 10中安装了conda 4.7.11。OpenCV可以很容易地安装在Anaconda Navigator中。启动Navigator后,单击左侧面板上的Environments。在顶部的下拉菜单中,选择“未安装”。然后搜索py-opencv,勾选左边的复选框来安装它。它将安装依赖包libopencv。我在Spyder中使用import cv2来访问它。

虽然不是通过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