我已经安装了LibreOffice(6.3.4.2),还有
pip install unoconv
和 pip install unotools
(pip install uno
是另一个无关的库),但是在import uno
之后仍然出现了以下错误:
更一般地说,作为使用UNO的示例,如何使用LibreOffice UNO打开.docx文档并将其导出为PDF?ModuleNotFoundError: No module named 'uno'
我已经在Windows上广泛搜索了几天,但是我没有找到一个可重现的示例代码:
headless use of
soffice.exe
, see my question+answer Headless LibreOffice very slow to export to PDF on Windows (6 times slow than on Linux) and the notes on the answer: it "works" withsoffice.exe --headless ...
but something closer to a COM interaction (Component Object Model) would be useful for many applications, thus this question hereRelated forum post, and LibreOffice: Programming with Python Scripts, but the way uno should be installed on Windows, with Python, is not detailed; also Detailed tutorial regarding LibreOffice to Python macro writing, especially for Calc
I've also tried this (unsuccessfully): Getting python to import uno / pyuno:
import os os.environ["URE_BOOTSTRAP"] = r"vnd.sun.star.pathname:C:\Program Files\LibreOffice\program\fundamental.ini" os.environ["PATH"] += r";C:\Program Files\LibreOffice\program" import uno