Bug 136001 - Python import fails: No module named 'com'
Summary: Python import fails: No module named 'com'
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.4.6.2 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: possibleRegression
Depends on:
Blocks: UNO
  Show dependency treegraph
 
Reported: 2020-08-21 22:22 UTC by Jens Troeger
Modified: 2023-05-24 15:04 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Troeger 2020-08-21 22:22:39 UTC
Description:
We have just updated to LibreOffice 6.4.6.2 40(Build:2), and now Python’s modules fail to import:

$ PYTHONPATH=/usr/lib64/libreoffice/program/ python3.8
Python 3.8.5 (default, Aug 21 2020, 13:17:56) 
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import uno
>>> from com.sun.star.text import ReferenceFieldSource
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/libreoffice/program/uno.py", line 436, in _uno_import
    raise uno_import_exc
  File "/usr/lib64/libreoffice/program/uno.py", line 358, in _uno_import
    return _builtin_import(name, *optargs, **kwargs)
ImportError: No module named 'com' (or 'com.sun.star.text.ReferenceFieldSource' is unknown)
>>> 

Same with Python 3.7. Now rolling back to 6.4.5.2 which hopefully fixes the issue. 

Is this a regression? Something I’m missing? Anything changed here? I noticed that 6.4.6.2 is not listed below as an “official” release?

Steps to Reproduce:
See above.

Actual Results:
Python import exception.

Expected Results:
Successful import of Python modules.


Reproducible: Always


User Profile Reset: Yes



Additional Info:
Built LO on a Gentoo box:

[ebuild   R    ] app-office/libreoffice-6.4.6.2::gentoo  USE="dbus mariadb postgres -accessibility -base -bluetooth -branding -coinmp -cups -debug -eds -firebird -googledrive -gstreamer -gtk -java -kde -ldap -odk -pdfimport -test" LIBREOFFICE_EXTENSIONS="-nlpsolver -scripting-beanshell -scripting-javascript -wiki-publisher" PYTHON_SINGLE_TARGET="python3_7 -python3_6 -python3_8 -python3_9" 0 KiB
Comment 1 Kevin Suo 2020-10-21 06:21:10 UTC Comment hidden (obsolete)
Comment 2 Kevin Suo 2020-10-22 07:34:13 UTC
I do reproduce with version 6.4.6.2 release and also on libreoffice-7-0 branch, when running:
from com.sun.star.text import ReferenceFieldSource.

The first import, "import uno" is successful.
Comment 3 Kevin Suo 2020-10-23 09:31:48 UTC
The import of com.sun.start.* is successful when I use the python shell with the following extension:
https://extensions.libreoffice.org/en/extensions/show/apso-alternative-script-organizer-for-python
Comment 4 Julien Nabet 2022-01-22 16:38:35 UTC
On pc Debian x86-64 with master sources updated today, I don't reproduce this.
Python 3.8.12 (default, Jan 22 2022, 17:24:40) 
[Clang 13.0.1 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import uno
>>> from com.sun.star.text import ReferenceFieldSource
>>> 

Debian testing provides LO 7.3.0.2, I don't see any Python binary in a "libreoffice" subdir in "/usr" so can't test it.
Comment 5 Werner Tietz 2022-10-29 12:43:29 UTC
@Julien Nabet
the python-interpreter on Debian (also linked to LO ) is: /usr/bin/python
Comment 6 Werner Tietz 2022-10-29 12:45:05 UTC Comment hidden (obsolete)