tutorcruncher/pydf

Error while loading shared libraries: libjpeg.so.8

malikovss opened this issue · 11 comments

I couldn't use pydf inside docker.
I am using pypoetry. And I installed packages like this.

FROM python:3.8
RUN mkdir /src
WORKDIR /src
COPY . /src
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
ENV PATH="/root/.poetry/bin:$PATH"
COPY pyproject.toml poetry.lock /opt/project/
RUN poetry config virtualenvs.create false && \
    poetry install --no-dev

COPY . /opt/project/
RUN poetry install  --no-dev

It is my code where I used pydf

from pydf import AsyncPydf
from io import BytesIO

apydf = AsyncPydf()

async def pdf_file():
    pdf_content = await apydf.generate_pdf("<h1>hello world</h1>")
    bytes_ = BytesIO(pdf_content)
    bytes_name = "file.pdf"
    return bytes_

It raises error

File "/src/ptime/core/tools.py", line 189, in pdf_file
pdf_content = await apydf.generate_pdf("<h1>hello world</h1>")
File "/usr/local/lib/python3.8/site-packages/pydf/wkhtmltopdf.py", line 73, in generate_pdf
raise RuntimeError('error running wkhtmltopdf, command: {!r}\n'
RuntimeError: error running wkhtmltopdf, command: ['/usr/local/lib/python3.8/site-packages/pydf/bin/wkhtmltopdf', '--cache-dir', '/tmp/pydf_cache', '-', '-']
response: "/usr/local/lib/python3.8/site-packages/pydf/bin/wkhtmltopdf: error while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory"

How can I fix this?

Looks like you need to install libjpeg.

You'll need to add something like

 RUN apt-get install -y --no-install-recommends libjpeg-dev

@samuelcolvin Thank you for your answer. but it did not work.

libjpeg-dev is already the newest version (1:1.5.2-2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

yes, just found that, looking into it

Looks like it's caused by the old version of wkhtml we're using, see #22

Having this same issue too using docker python:3.9-slim-buster

Having this same issue too using docker python:3.9-slim-buster

write your own image.

FROM ubuntu:20.04
RUN apt-get update && \
    apt-get install -y curl && \
    apt-get install -y python3.8 && \
    apt-get install -y python3-pip && \
    apt-get install -y python3.8-dev && \
    apt-get install -y wget && \
    wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb && \
    apt-get install -y ./wkhtmltox_0.12.6-1.focal_amd64.deb

Having this same issue too using docker python:3.9-slim-buster

write your own image.

FROM ubuntu:20.04
RUN apt-get update && \
    apt-get install -y curl && \
    apt-get install -y python3.8 && \
    apt-get install -y python3-pip && \
    apt-get install -y python3.8-dev && \
    apt-get install -y wget && \
    wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb && \
    apt-get install -y ./wkhtmltox_0.12.6-1.focal_amd64.deb

Hey thanks for the idea but i simply added the commit to my requirements file as this:
git+https://github.com/tutorcruncher/pydf.git@287c2d6041a5adb8be3671212e9324df23785675

This just imported the merge request to my libraries and it works correctly.

Hi! @samuelcolvin
Have you read last comment?
Can you merge request if it is working correctly

Sorry, is there a PR you want me to merge?

#22
I thought if you merge it. This error will be fixed

See my comment on #22, I'm still getting the same libjpeg error when using that branch, and tests are failing with that error too.