gpt4 book ai didi

python-3.x - 如何在 Docker 容器中运行 pdfkit from_file

转载 作者:行者123 更新时间:2023-12-02 03:31:56 24 4
gpt4 key购买 nike

以下是我的 Docker 代码:

FROM python:3.6.2-jessie

## Prepare apt-get:
RUN echo "debconf debconf/frontend select Noninteractive" | debconf-set-selections && \
apt-get update -qy && \
apt-get upgrade -qy && \
apt-get clean autoclean && \
apt-get install wkhtmltopdf -y && \
apt-get autoremove -y && \
apt-get install python3-setuptools -qy &&\
apt-get install python3-dev -qy && \
apt-get install python3-pip -qy && \
apt-get install build-essential -qy && \
apt-get -y install openssh-client -qy && \
apt-get clean

RUN pip3 install --upgrade pip
RUN pip3 install pandas
RUN pip3 install psycopg2==2.7.3.2
RUN pip3 install pdfkit

当我运行以下代码时,

docker run my_image python3 pdfkit.py

我收到以下错误:

OSError: wkhtmltopdf exited with non-zero code -6. error: The switch --viewport-size, is not support using unpatched qt, and will be ignored.The switch --disable-smart-shrinking, is not support using unpatched qt, and will be ignored.QXcbConnection: Could not connect to display

最佳答案

尝试以下操作:

RUN curl -L#o wk.tar.xz https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz \
&& tar xf wk.tar.xz \
&& cp wkhtmltox/bin/wkhtmltopdf /usr/bin \
&& cp wkhtmltox/bin/wkhtmltoimage /usr/bin \
&& rm wk.tar.xz \
&& rm -r wkhtmltox

而不是直接使用 apt-get install wkhtmltopdf -y 安装。

关于python-3.x - 如何在 Docker 容器中运行 pdfkit from_file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51623777/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com