python3安装cv2模块_Anaconda:即使已安装opencv,也无法导入cv2(如何为python3安装opencv3)...

在Ubuntu 16.04上使用Anaconda(conda 4.2.9,python3)时,作者遇到了导入cv2模块时的错误。尽管尝试了conda搜索cv2,但只找到适用于Python2的版本。解决方案是安装适用于Python3的opencv3。通过运行特定的conda命令从'menpo'或'conda-forge'通道安装opencv3,可以成功解决此问题。
摘要由CSDN通过智能技术生成

I have anaconda (version: conda 4.2.9, python3) installed and am trying to do import cv2 when I get the following error:

ImportError: No module named 'cv2'

With conda search cv2 I get this:

opencv 2.4.2 np15py26_0 defaults

2.4.2 np15py27_0 defaults

2.4.2 np16py26_0 defaults

2.4.2 np16py27_0 defaults

2.4.2 np17py26_0 defaults

2.4.2 np17py27_0 defaults

2.4.2 np15py26_1 defaults

2.4.2 np15py27_1 defaults

2.4.2 np16py26_1 defaults

2.4.2 np16py27_1 defaults

2.4.2 np17py26_1 defaults

2.4.2 np17py27_1 defaults

2.4.6 np16py26_0 defaults

2.4.6 np16py27_0 defaults

2.4.6 np17py26_0 defaults

2.4.6 np17py27_0 defaults

2.4.6 np18py26_0 defaults

2.4.6 np18py27_0 defaults

2.4.9 np18py27_0 defaults

2.4.10 np19py26_0 defaults

2.4.10 np19py27_0 defaults

2.4.10 np110py27_1 defaults

2.4.10 np19py26_1 defaults

2.4.10 np19py27_1 defaults

What do I need to do to be able to import the cv2 module? Thanks!

PS: I am using Ubuntu 16.04

解决方案

opencv is not compatible with python 3. I had to install opencv3 for python 3. The marked answer in how could we install opencv on anaconda? explains how to install opencv(3) for anaconda:

Run the following command:

conda install -c https://conda.binstar.org/menpo opencv

I realized that opencv3 is also available now, run the following command:

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

Edit on Aug 18, 2016: You may like to add the "menpo" channel permanently by:

conda config --add channels menpo

And then opencv can be installed by:

conda install opencv (or opencv3)

Edit on Aug 14, 2017: "clinicalgraphics" channel provides relatively newer vtk version for very recent python3

conda install -c clinicalgraphics vtk

Edit on April 16, 2020 (based on @AMC's comment): OpenCV can be installed through conda-forge (details see here)

conda install -c conda-forge opencv

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值