当我尝试使用import cv2python时,出现以下错误:

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

我找到了建议安装的线程libgl1-mesa-glx,但我想知道是否仅在Ubuntu上可用,因为我在CentOS上,当我尝试sudo yum install libgl1-mesa-glx获取时,No package libgl1-mesa-glx available.另外,当我将安装添加到dockerfile时,出现此错误:The command '/bin/sh -c yum install libgl1-mesa-glx' returned a non-zero code: 1

然后,我发现了看起来像Fedora的解决方案,该解决方案用于所说的相同问题mesa-libGL-devel。当我sudo yum install mesa-libGL-devel似乎可以正确安装时,但是当我将其添加到我的dockerfile中时,我得到了The command '/bin/sh -c yum install mesa-libGL-devel' returned a non-zero code: 1

我还应该尝试什么?

编辑:这是Dockerfile:

FROM nvidia/cuda:10.1-cudnn7-devel-centos7

WORKDIR /app/
COPY ./*.* ./
ENV CONDA_DIR "/opt/conda"
ENV PATH "$CONDA_DIR"/bin:$PATH
ONBUILD ENV PATH "$CONDA_DIR"/bin:$PATH

RUN  \
   yum -y install epel-release && \
    yum -y update && \
    yum install -y \
    bzip2 \
    curl \
    which \
    libXext \
    libSM \
    libXrender \
    git \
    cuda-nvcc-10-1 \
    openssh-server \
    postgresql-devel \
    yum clean all && rm -rf /var/cache/yum/*


RUN CONDA_VERSION="4.5.1" && \
    curl -L \
       https://repo.continuum.io/miniconda/Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh -o miniconda.sh && \
    mkdir -p "$CONDA_DIR" && \
    bash miniconda.sh -f -b -p "$CONDA_DIR" && \
    echo "export PATH=$CONDA_DIR/bin:\$PATH" > /etc/profile.d/conda.sh && \
    rm miniconda.sh && \
    conda config --add channels conda-forge && \
    conda update -y conda && \
    conda config --set auto_update_conda False && \
    pip install --upgrade pip && \
    pip install -r requirements.txt && \
    rm -rf /root/.cache/pip/* && \
    conda install gdal==2.4.2 tensorflow-gpu numpy==1.16.5


RUN conda env create -f py2_env.yaml
RUN conda env create -f py3_env.yaml

#Add gdal
RUN yum update -y
RUN yum upgrade -y
RUN yum install -y gcc python3-dev python3-pip libxml2-dev libxslt1-dev zlib1g-dev g++

RUN export CPLUS_INCLUDE_PATH=/usr/include/gdal
RUN export C_INCLUDE_PATH=/usr/include/gdal
RUN yum install -y gdal libgdal-dev gdal-devel 
#RUN /opt/conda/envs/py2/bin/pip install gdal==2.4.2
RUN /opt/conda/envs/py3/bin/pip install gdal==2.4.2


RUN /bin/bash -c "conda init bash && source /root/.bashrc && conda activate py2 && conda install -y notebook ipykernel && ipython kernel install --user && conda deactivate"

RUN /bin/bash -c "conda init bash && source /root/.bashrc && conda activate py3 && conda install -y notebook ipykernel && ipython kernel install --user && conda deactivate"

只需添加以下命令:

yum install mesa-libGL