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:
How to make C# connect only to an encrypted Access fileThe problem is that it connects to the encrypted file by password, but if you decrypt the Access file, it still connects I did so, but anyway, if th… Read More
Some AWS lamba execution have more than 1 S3event keyI'm having an issue when passing events to the AWS lambda function. I have to sync 60k data in 1 json file to a remote server. My solution is to divid… Read More
search bar causing infinite loop in ReactHere's parent component: const Page = () = { const { user } = useAuth(); const router = useRouter(); const [allUsers, setAllUsers] = useState([]);… Read More
bash: How to check if variable exists when set -eu option is setIn one of my prod script set -eu is set. In this script I want to check if variable exists but -v and -z option is not working. #!/bin/bash set -eu se… Read More
LINQ Query returning an empty resultI am fairly new to LINQ and am having problems with a query. var LoadDetentionTypes = _db.Settings_DetentionTypes .Where(f = SchoolAreaList.Any(s = f… Read More
0 comments:
Post a Comment
Thanks