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

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

我正在尝试 运行 我在 Bitbucket-pipeline 中的测试用例,但它正在显示 一条错误消息。

Bitbucket截图-pipeline.yml

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   import cv2
E   ImportError: libopencv_hdf.so.3.1: cannot open shared object file: No such file or directory

**ImportError**

您可能没有安装 opencv3.1 或安装不正确,这就是您无法导入它的原因。

谢谢,我找到了答案。我在冗余时间安装 opencv,所以它重叠并从自身删除了一些重要的模块。 这是我来自 Bitbucket 的脚本-pipeline.yml

    image: python:3.6.2
pipelines:
  default:
    - step:
        caches:
          - condacache
        script:
          - wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
          - chmod +x Miniconda3-latest-Linux-x86_64.sh
          - ./Miniconda3-latest-Linux-x86_64.sh -u -b -p /opt/python
          - cd marvin_oms
          - /opt/python/bin/conda update -y conda
          - /opt/python/bin/pip install --upgrade pip
          - /opt/python/bin/conda install -y numpy pandas SQLAlchemy requests lxml  virtualenv psycopg2
          - apt-get update && apt-get install -y libzbar0 libzbar-dev libgtk2.0-0
          - /opt/python/bin/pip install pyzbar
          - /opt/python/bin/conda install seaborn opencv=3.1.0 scipy libgcc boost=1.61.0 libpng=1.6.27 cython
          - /opt/python/bin/pip install libraries/imgforensics-0.1-cp36-cp36m-linux_x86_64.whl
          - /opt/python/bin/pip install -r requirements.txt
          - /opt/python/bin/pytest

definitions:
  caches:
    condacache: /opt/python/bin

那是因为您可能粘贴了另一个重叠的 cv2.so 文件继续并打开终端并输入

cd /lib/python3/dist-packages
and then
ls

你会看到 cv2.so ,将它复制到桌面上作为备份,以防万一我错了你不会丢失它

类型:

cp cv2.so /home/ubuntu/cv2.so

然后输入这个删除它

rm cv2.so

现在输入

python3
import cv2

大功告成...

概念验证:

check here the image

删除后:

last one after importing