作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下是我的 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/
以下是我的 Docker 代码: FROM python:3.6.2-jessie ## Prepare apt-get: RUN echo "debconf debconf/frontend sel
以下是我的 Docker 代码: FROM python:3.6.2-jessie ## Prepare apt-get: RUN echo "debconf debconf/frontend sel
我是一名优秀的程序员,十分优秀!