如何编写Dockerfile来运行Python3 + PyQt5

问题描述 投票:0回答:1

故事是,我已经使用Python3.8,PyQt5和Postgres构建了一个小的Python软件,因此我试图创建一个容器以对所有这些东西进行Docker化,我正在考虑创建一个Dockerfile来创建用于python + pqt5,另一个仅用于Postgres的容器,然后使用docker-compose链接所有内容。

问题是,当我尝试为Python和PyQt5创建容器时,遇到了此错误。

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

这实际上是我正在谈论的Dockerfile

FROM python:3

COPY *.py /code/
COPY requirements.txt /code/

WORKDIR /code/

RUN apt-get update -y && apt-get upgrade -y && \
    apt-get install xvfb -y

RUN pip install --no-cache-dir -r requirements.txt

CMD ["python3", "main.py"]

这是我的Requirements.txt的内容

psycopg2
requests
PyQt5

我尝试了在网上找到的所有解决方案,以及在Docker Hub上找到的其他解决方案,但没有一个给我预期的结果。

任何善良的灵魂可以阐明这个问题吗?最好使用书面代码。

python qt docker pyqt5
1个回答
0
投票

您有解决方案吗?我也在尝试相同的方法,并花了很多时间为此找到解决方案,但没有运气。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.