[Python] How to add doc2pdf to custom docker container

Discussão em 'Python' iniciado por Stack, Julho 8, 2025.

  1. Stack

    Stack Membro Participativo

    I want to use doc2pdf program in my python:3.9-slim-bullseye container

    I added libreoffice-writer unoconv to my container

    Dockerfile

    FROM python:3.9-slim-bullseye
    WORKDIR /project
    ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONBUFFERED=1

    COPY . .
    RUN apt-get update && apt-get install --no-install-recommends -y \
    libreoffice-writer unoconv \
    gcc libc-dev libpq-dev python-dev libxml2-dev libxslt1-dev python3-lxml && apt-get install -y cron &&\
    pip install --no-cache-dir -r requirements.txt


    Then I logged in my container and received error below

    docker-exec -ti <Container_NAME> bash

    root@cfdbb27947c6:/project/documents_app/templates# doc2pdf doc_1.docx
    unoconv: Cannot find a suitable pyuno library and python binary combination in /usr/lib/libreoffice
    ERROR: No module named 'uno'

    unoconv: Cannot find a suitable office installation on your system.
    ERROR: Please locate your office installation and send your feedback to:
    http://github.com/dagwieers/unoconv/issues
    root@cfdbb27947c6:/project/documents_app/templates#


    How can i fix the error?

    UPDATE 1 Was trying to install python3-uno but it didn't help

    Also added this

    uno==0.3.3
    base==1.0.4
    unotools


    but still have errors

    Continue reading...

Compartilhe esta Página