I am doing this with Python and LibreOffice. I have installed everything, but it always gives me an error message with uno, although I have inhaled it. With Python, I actually always need venv.
I once asked ChatGPT for a Python script:
import subprocess
import os
def convert_pdf_to_odt(pdf_file):
# Überprüfen, ob die Datei existiert
if not os.path.exists(pdf_file):
print(f"Die Datei {pdf_file} wurde nicht gefunden.")
return
# Zielpfad: gleiche Datei mit der Endung .odt
output_file = os.path.splitext(pdf_file)[0] + '.odt'
try:
# Verwende unoconv, um das PDF in ODT zu konvertieren
subprocess.run(['unoconv', '-f', 'odt', pdf_file], check=True)
print(f"Erfolgreich konvertiert: {pdf_file} -> {output_file}")
except subprocess.CalledProcessError as e:
print(f"Fehler bei der Konvertierung: {e}")
if __name__ == "__main__":
# Beispiel-PDF-Datei (Pfad zur Datei anpassen)
pdf_file = '/home/ben/convert-commander/test/pdfs/Bild4.pdf'
# Konvertiere die PDF-Datei in ODT
convert_pdf_to_odt(pdf_file)
When executing, it gives me the error message:
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
/> Fehler bei der Konvertierung: Command '['unoconv', '-f', 'odt', '/home/ben/convert-commander/test/pdfs/Bild4.pdf']' returned non-zero exit status 1.
As I said, I am in a venv
Can you help me?
Thanks!
(translated with deepl from german)
0 comments:
Post a Comment
Thanks