ImportError:libopencv_hdf.so.3.1:无法打开共享对象文件:没有这样的文件或目录

时间:2018-05-26 11:29:29

标签: python-3.x pip conda opencv3.1 bitbucket-pipelines

我正在尝试在Bitbucket管道中运行我的测试用例,但它正在显示 错误信息。

Bitbucket-pipeline.yml的屏幕截图

enter image description here

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

**ImportError**

3 个答案:

答案 0 :(得分: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

答案 1 :(得分:1)

那是因为您可能已经粘贴了另一个重叠的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

答案 2 :(得分:0)

你可能没有安装opencv3.1或没有正确安装,导致它无法导入。