简体   繁体   中英

After installing opencv3.3,import cv2 gives “libopencv_imgcodecs.so.3.1: cannot open shared object file”

I have cleaned opencv 3.1 from ubuntu 16.04

run "sudo cat install_manifest.txt | xargs echo sudo rm | sh" 
and rm cv2.so from /usr/lib/python2.7/dist-packages/cv2.so,

upgrade to 3.3 manually(cmake/make/make install) then

sudo ldconfig
run:ldd /usr/lib/python2.7/dist-packages/cv2.so

got

linux-vdso.so.1 =>  (0x00007ffc85de1000)
    libopencv_hdf.so.3.3 => /usr/lib/x86_64-linux-gnu/libopencv_hdf.so.3.3 (0x00007f605d4bd000)
    libopencv_reg.so.3.3 => /usr/lib/x86_64-linux-gnu/libopencv_reg.so.3.3 (0x00007f605cf8a000)

but under ipython

  import cv2

gives me:

ImportError: libopencv_imgcodecs.so.3.1: cannot open shared object file: No such file or directory

Obviously,it is trying to use previous version,and it seems something has been cached,am I right?How to solve this problem?

I got exactly the same issue.Corrected now. You can check the module path in python :

import sys
print(sys.path)

This will show you were python is trying to catch the cv2.so when doing import cv2. Then check in all the folders mentioned in the print result if an old cv2.so or a symlink is not remaining, so taking place of the new one you try to use.

It could be simply in the '.' current folder as '.' is part of the syspath.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM