opencv 与 python 模块有不同的版本 [英] opencv have different version with python module

查看:119
本文介绍了opencv 与 python 模块有不同的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将 opencv 安装到我的 ubuntu 14.04LTS,但是我有两个版本.完成安装后.我尝试以下命令:

I have install the opencv to my ubuntu 14.04LTS,But I have got two version .After I have done the install.I try the below command:

pkg-config --modversion opencv

我得到了版本:3.0.0当我在 python shell 上工作时

I got the version: 3.0.0 And when i work it on python shell

>>import cv2
>>cv2.__version__
'2.4.8'

当我按照这个http://docs.opencv.org/trunk/d5/d26/tutorial_py_knn_understanding.html#gsc.tab=0我收到了一些错误消息,说'cv2 没有模块'ml''所以,我发现这是因为我猜我的 opencv 版本与本教程不匹配!任何人都可以帮忙,为什么我的 opencv 与 python 模块不匹配?

When I follow this http://docs.opencv.org/trunk/d5/d26/tutorial_py_knn_understanding.html#gsc.tab=0 I got some error said 'cv2 have not module 'ml''so,I find it's because i guess my opencv version did't match this tutorial! Can anyone help, why my opencv did't match the python mudule?

推荐答案

还需要一个步骤.您需要将新创建的库文件 -cv2.so- 符号链接到您的 python 包路径.详细信息可以在本说明的最后一部分 PyImageSearch 文章 - 在 Ubuntu 上安装 OpenCV 3.0 和 Python 2.7+

One more step is needed. You need to symbolically link your newly created library file -cv2.so- to your python package path. Details can be found in the last part of this instruction PyImageSearch article - Install OpenCV 3.0 and Python 2.7+ on Ubuntu

由于您已经安装了 OpenCV,因此链接库文件已经存在,您需要先将其删除.如果我运行下面的文件"命令,则从 Docker Ubuntu 14.04LTS 实例中显示:

Since you already have OpenCV installed a linked library file already exists and you will need to remove it first. From a Docker Ubuntu 14.04LTS instance here if I run the 'file' command below it shows:

文件/usr/local/lib/python2.7/site-packages/cv2.so

file /usr/local/lib/python2.7/site-packages/cv2.so

/usr/local/lib/python2.7/site-packages/cv2.so:符号链接`/usr/lib/python2.7/dist-packages/cv2.so'

/usr/local/lib/python2.7/site-packages/cv2.so: symbolic link to `/usr/lib/python2.7/dist-packages/cv2.so'

因此,您需要使用rm"删除该符号链接并使用以下命令创建一个新链接:

So you need to remove that symbolic link with 'rm' and create a new one with this command:

ln -s ~新 cv2.so 文件的路径 ~/usr/local/lib/python2.7/site-packages/cv2.so

ln -s ~path to your new cv2.so file~ /usr/local/lib/python2.7/site-packages/cv2.so

这样你应该能够启动 python,导入 cv2,并确认新版本的 OpenCV 已启用.享受教程.

With that you should be able to fire up python, import cv2, and confirm the new version of OpenCV is enabled. Enjoy the tutorial.

这篇关于opencv 与 python 模块有不同的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆