ImportError: libGL.so.1 on CentOS

南楼画角 提交于 2021-01-28 05:00:46

问题


When I try to import cv2 in python I get the following error:

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

I found this thread which suggested I install libgl1-mesa-glx, but I'm wondering if that's only available on Ubuntu because I'm on CentOS and when I try to sudo yum install libgl1-mesa-glx I get No package libgl1-mesa-glx available. Also, when I added the installation to my dockerfile I got this error: The command '/bin/sh -c yum install libgl1-mesa-glx' returned a non-zero code: 1

Then I found what looked like a Fedora solution to the same problem that said to use mesa-libGL-devel. When I sudo yum install mesa-libGL-devel it appears to install correctly, but when I added that to my dockerfile I get The command '/bin/sh -c yum install mesa-libGL-devel' returned a non-zero code: 1.

What else should I try?

EDIT: Here is the 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"

回答1:


Just add this command:

yum install mesa-libGL


来源:https://stackoverflow.com/questions/60628083/importerror-libgl-so-1-on-centos

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!