ImportError:OpenShift Online平台上的libXrender.so.1



我在OpenShift Online Platform上用streamlit、PyTorch和OpenCV构建了一个web应用程序。它一直运行良好,直到它开始执行Python脚本:

Traceback (most recent call last):
File "app.py", line 11, in <module>
import cv2
File "/opt/app-root/lib/python3.6/site-packages/cv2/__init__.py", line 3, in <module>
from .cv2 import *
ImportError: libXrender.so.1: cannot open shared object file: No such file or directory

我知道它的解决方案是简单地安装缺失的库";libXrender";。但问题是我找不到实现它的方法(我已经尝试过docker了(。那么,在OpenShift在线平台上打开终端控制台是可能的吗?

PS:我正在使用OpenShift的入门包,下面是我的Dockerfile:

FROM pytorch/pytorch:1.4-cuda10.1-cudnn7-runtime
RUN pip install virtualenv
# only needed when using OpenShift
RUN apt-get install libxrender1
ENV VIRTUAL_ENV=/venv
RUN virtualenv venv -p python3
ENV PATH="VIRTUAL_ENV/bin:$PATH"
WORKDIR /app
ADD . /app
# Install dependencies
RUN apt update
RUN apt-get install -y libglib2.0-0 libsm6 libxrender1 libxext6
RUN pip install -r requirements.txt
# copying all files over
COPY . /app
# Expose port 
ENV PORT 8501
# cmd to launch app when container is run
CMD streamlit run app.py
# streamlit-specific commands for config
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
RUN mkdir -p /root/.streamlit
RUN bash -c 'echo -e "
[general]n
email = ""n
" > /root/.streamlit/credentials.toml'
RUN bash -c 'echo -e "
[server]n
enableCORS = falsen
" > /root/.streamlit/config.toml'

在不知道requirements.txt中有什么的情况下,我相信您可以通过安装opencv-python的无头版本(服务器环境(来解决这个问题,即opencv-python-headless。那么您很可能也可以删除libsm6 libxrender1 libxext6。这些依赖项用于显示GUI窗口,而在服务器(无头(环境中通常不需要这些窗口。

相关内容

最新更新