240
笔下虽有千言,胸中实无一策

[Debug] Make python2.7 use the right version of opencv

Bug:

Some day I updated my openCV to the latest version 2.4.13, while recently I found I always get "2.4.8" when I check the version in python2.7. It is wired and anoiying. Also it is normal in C++.

This bug is quite similar with this one: opencv have different version with python module. Luckily the answer works. Also refer to PyImageSearch article - Install OpenCV 3.0 and Python 2.7+ on Ubuntu.

Fix:

It is related to the symbolically link problem. I was wasting time reinstalling openCV-2.4.13 for several times.

In all, after installing the new version of openCV, one more step is needed. We need to symbolically link our newly created library file -cv2.so- to our python package path.

Let's say

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

which is usually the case.

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

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

here it shall be

  ln -s /usr/local/lib/python2.7/site-packages/cv2.so ~/usr/local/lib/python2.7/site-packages/cv2.so

posted @ 2017-01-26 03:06  CasperWin  阅读(233)  评论(0编辑  收藏  举报