I only have problems with my new project. I want to build a file converter.
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)
Error with uno module when using unoconv for file conversion in Python: 'Cannot find a suitable pyuno library' despite venv setup
Programing Coderfunda
September 05, 2024
No comments
Related Posts:
Laravel Console Spinner aravel Console Spinner is a custom spinning progress bar for Laravel inspired by the Symfony Console Spinner:This package is specifically f… Read More
Use Apache Kafka With LaravelLaravel Kafka is a package for using Apache Kafka producers and consumers in your Laravel app with ease. Using the publishOn … Read More
Define Model Attributes With Laravel FluentLaravel Fluent is a package by Boris Lepikhin that provides an expressive way to define model attributes. This package automatically bu… Read More
Laravel Migration ActionsLaravel migration actions is like version control for your migration process, allowing your team to modify and share the application's actio… Read More
Vue Lazy Image ComponentVue Lazy Image is a Vue.js component to lazy-load an image automatically when it enters the viewport using the Intersection Observer API.Usi… Read More
0 comments:
Post a Comment
Thanks