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:
R - In a for loop iterating through columns df[[i]] if a data frame, how do I print the name of column df[[i]] for each loop?I'm trying to use a for-loop to iterate through the columns of a data frame, and for each loop print out the name of the column on each loop before th… Read More
Since when did Laravel fill ONLY database fields into a Model?I recently upgraded a Laravel application and came across some strange bugs. It turns out, the fill() method on models doesn't fill all fields anymore… Read More
Compiler Not Recognized (GCC for Visual Studio Code)Despite installing the compiler and adding the path to my user environment variable path, the compiler isn't recognized when I test it by checking the… Read More
AWS Glue Python Shell Upgrade Boto3 Library without Internet AccessI need to use a newer boto3 package for an AWS Glue Python3 shell job (Glue Version: 1.0). The default version is very old and hence all the API's d… Read More
Laravel Breeze with Volt Functional API--- The Laravel team released the Livewire + Volt functional stack for Breeze. This increases the Breeze offering to six stack variations, offerin… Read More
0 comments:
Post a Comment
Thanks