python安装opencv模块,在Ubuntu上安装Python的OpenCV并得到ImportError:没有名为cv2.cv的模块...

I have an Ubuntu 14.04 system, on which I want to install OpenCV and use it with Python 2.x.

I installed OpenCV using the instructions here:

https://help.ubuntu.com/community/OpenCV

The install seemed to run properly, no errors, the script ended with output

OpenCV 2.4.9 ready to be used

When I try to run the sample Python script, I get the following:

$ python opencv.py

Traceback (most recent call last):

File "opencv.py", line 1, in

from cv2.cv import *

ImportError: No module named cv2.cv

I suspect I know why, I just don't know how to fix it. OpenCV installed to the current directory I was in when I ran the install script, it's a subdirectory of my home folder.

Others who get this import error after install seem to be having a path issue, and have luck adding this to their code:

import sys

sys.path.append('/usr/local/lib/python2.7/site-packages')

or updating their PYTHONPATH with that same directory. I tried adding that code, it doesn't make a difference. I don't see any files in the "site-packages" directory. Should I have done the install in that directory? I imagine the installation instructions would have spelled that out. I suspect that my problem has to do with Python not finding the OpenCV install, but I'm not sure how to proceed.

Please help me get a usable install of OpenCV as simply as possible.

解决方案

I think you don't have the python-opencv package.

I had the exact same problem and

sudo apt-get install python-opencv

solved the issue for me.

you can install opencv from the following link

https://www.learnopencv.com/install-opencv3-on-ubuntu/

It works for me .

apt-get install doesnt contain many packages of opencv

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值