简体   繁体   English

LibreOffice 'uno' 模块不适用于 Python 3.10?

[英]LibreOffice 'uno' module will not work with Python 3.10?

When attempting to import uno under a Python 3.10 install, Python throws an error:在 Python 3.10 安装下尝试import uno时,Python 会抛出错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\libreoffice7.3.4\program\uno.py", line 19, in <module>
    import pyuno
ImportError: Module use of python38.dll conflicts with this version of Python.

Per research, the culprit is indeed the "python38.dll", which is a file in the Python 3.8 install that LibreOffice needs to do its Python stuff.根据研究,罪魁祸首确实是“python38.dll”,它是 Python 3.8 安装中的一个文件,LibreOffice 需要执行它的 Python 工作。 The catch is, I don't have that dll, I have "python310.dll", and I cannot see how to tell LibreOffice (v. 7.3.4) to look for that dll instead.问题是,我没有那个 dll,我有“python310.dll”,而且我看不到如何告诉 LibreOffice (v. 7.3.4) 去寻找那个 dll。

I have tried to update the PYTHONPATH environment variable to point at the 310.dll, and I have made sure that I only have one version of Python installed with $ py -01p .我尝试更新PYTHONPATH环境变量以指向 310.dll,并且我确保我只安装了一个带有$ py -01p的 Python 版本。

Searching within the LibreOffice files/forums has not turned up anything, either.在 LibreOffice 文件/论坛中搜索也没有发现任何东西。 Apparently LibreOffice 7.2 shipped with Python 3.8, and the LibreOffice 7.3 release notes' "Python" field is empty.显然 LibreOffice 7.2 附带 Python 3.8,而 LibreOffice 7.3 发行说明的“Python”字段为空。

Am I just SOL trying to use Python to interact with LibreOffice until they maybe fix the issue with 7.4?我只是 SOL 试图使用 Python 与 LibreOffice 交互,直到他们可能用 7.4 解决问题?

After reinstalling Python (multiple versions, including 3.8) and LibreOffice several times, digging through settings files, and reading half a dozen sites on the topic, I finally arrived upon a very simple solution.在多次重新安装 Python(多个版本,包括 3.8)和 LibreOffice,挖掘设置文件,并阅读了有关该主题的六个站点后,我终于找到了一个非常简单的解决方案。

There's a python.exe file in the Program folder of the LibreOffice install.在 LibreOffice 安装的 Program 文件夹中有一个 python.exe 文件。 This file is a python interpreter, and the Uno module works just fine when using this interpreter.这个文件是一个 python 解释器,使用这个解释器时 Uno 模块工作得很好。

Point VSCode (or similar) to that file, and problem is totally solved, unless there is some compelling reason to use Python 3.9 or 3.10.将 VSCode(或类似文件)指向该文件,问题就完全解决了,除非有一些令人信服的理由使用 Python 3.9 或 3.10。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM