简体   繁体   中英

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:

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. 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.

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 .

Searching within the LibreOffice files/forums has not turned up anything, either. Apparently LibreOffice 7.2 shipped with Python 3.8, and the LibreOffice 7.3 release notes' "Python" field is empty.

Am I just SOL trying to use Python to interact with LibreOffice until they maybe fix the issue with 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.

There's a python.exe file in the Program folder of the LibreOffice install. This file is a python interpreter, and the Uno module works just fine when using this interpreter.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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