OpenCV论坛告诉我我的问题与Linux有关,而不与OpenCV有关,因此我在这里问。
我有import cv2错误,请参见以下说明:
cv2.so在以下路径下:
/usr/local/lib/python2.7/dist-packages/cv2.so
/usr/local/lib/python3.5/dist-packages/cv2.so
我不知道为什么在每个python版本下都有cv2.so ,我用python3构建opencv
我添加了~/.bashrc文件:
export PYTHONPATH=/usr/local/lib/python3.5/dist-packages:$PYTHONPATH
但是,当我在python3运行时:
import cv2
它给了我这个信息:
Traceback (most recent call last): File "", line 1, in ImportError: libopencv_hdf.so.3.4: cannot open shared object file: No such file or directory File "", line 1, in ImportError: libopencv_hdf.so.3.4: cannot open shared object file: No such file or directory
我该如何解决? 谢谢你。
环境:
Ubuntu 16.04
OpenCV 3.4.0 build with `contrib`, `python3`, `python3-numpy`.
编译OpenCV3.4.0时的代码
PS :我已经安装了两次OpenCV3。 如果您需要我的首次CMake命令,请点击链接
我通过使用ldd检查共享依赖项发现了一个问题:
ldd /usr/local/lib/python3.5/dist-packages/cv2.so
linux-vdso.so.1 => (0x00007fffacda1000)
libopencv_hdf.so.3.4 => not found
libopencv_reg.so.3.4 => not found
libopencv_surface_matching.so.3.4 => not found
libopencv_xphoto.so.3.4 => not found
libopencv_freetype.so.3.4 => not found
libopencv_fuzzy.so.3.4 => not found
libopencv_img_hash.so.3.4 => not found
libopencv_bioinspired.so.3.4 => not found
libopencv_saliency.so.3.4 => not found
libopencv_ccalib.so.3.4 => not found
libopencv_rgbd.so.3.4 => not found
libopencv_structured_light.so.3.4 => not found
libopencv_aruco.so.3.4 => not found
libopencv_bgsegm.so.3.4 => not found
libopencv_face.so.3.4 => not found
libopencv_optflow.so.3.4 => not found
libopencv_stitching.so.3.4 => not found
libopencv_objdetect.so.3.4 => not found
libopencv_photo.so.3.4 => not found
libopencv_tracking.so.3.4 => not found
libopencv_plot.so.3.4 => not found
libopencv_text.so.3.4 => not found
libopencv_dnn.so.3.4 => not found
libopencv_ximgproc.so.3.4 => not found
libopencv_xfeatures2d.so.3.4 => not found
libopencv_ml.so.3.4 => not found
libopencv_shape.so.3.4 => not found
libopencv_video.so.3.4 => not found
libopencv_calib3d.so.3.4 => not found
libopencv_features2d.so.3.4 => not found
libopencv_flann.so.3.4 => not found
libopencv_highgui.so.3.4 => not found
libopencv_videoio.so.3.4 => not found
libopencv_imgcodecs.so.3.4 => not found
libopencv_imgproc.so.3.4 => not found
libopencv_core.so.3.4 => not found
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff9d06b2000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff9d03a9000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff9d0193000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff9cfdc9000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff9d10cd000)
任何人都可以给出非常详细的说明来解决此问题吗?
更新:
将... gitclone ... / opencv / build / lib添加到$ LD_LIBRARY_PATH,然后导入cv2,它给出以下信息:
Traceback (most recent call last): File "", line 1, in ImportError: /usr/local/lib/python3.5/dist-packages/cv2.so: undefined symbol: _ZTIN2cv3dnn19experimental_dnn_v35LayerE File "", line 1, in ImportError: /usr/local/lib/python3.5/dist-packages/cv2.so: undefined symbol: _ZTIN2cv3dnn19experimental_dnn_v35LayerE