unoconv / unoserver

MIT License
496 stars 69 forks source link

AttributeError: 'NoneType' object has no attribute 'supportsService' #65

Closed mbardelmeijer closed 1 year ago

mbardelmeijer commented 1 year ago

When converting a document from DOCX to PDF, we get the following error. With lower versions of LibreOffice, we haven't run into this.

Versions: LibreOffice 7.4.5.1 40(Build:1) (tested on 7.0.4.2 as well) unoserver 1.3 (tested 1.2 as well)

Input file mimetype: application/vnd.openxmlformats-officedocument.wordprocessingml.document

$ unoconvert input.docx output.pdf

INFO:unoserver:Starting unoconverter.
INFO:unoserver:Opening input.docx
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/unoserver/converter.py", line 173, in convert
    import_type = get_doc_type(document)
  File "/usr/local/lib/python3.8/dist-packages/unoserver/converter.py", line 43, in get_doc_type
    if doc.supportsService(t):
AttributeError: 'NoneType' object has no attribute 'supportsService'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/unoconvert", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/unoserver/converter.py", line 276, in main
    result = converter.convert(
  File "/usr/local/lib/python3.8/dist-packages/unoserver/converter.py", line 225, in convert
    document.close(True)
AttributeError: 'NoneType' object has no attribute 'close'
dexterbg commented 1 year ago

Same issue here, running on…

unoserver starts without issues:

# unoserver
INFO:unoserver:Starting unoserver.
INFO:unoserver:Command: libreoffice --headless --invisible --nocrashreport --nodefault --nologo --nofirststartwizard --norestore -env:UserInstallation=file:///tmp/tmprvf8kqu5 --accept=socket,host=127.0.0.1,port=2002,tcpNoDelay=1;urp;StarOffice.ComponentContext
INFO:unoserver:Server PID: 33008

unoconvert doesn't seem to connect to the server at all when trying to convert a file, or at least there is no sign of activity at the unoserver side.

# unoconvert BookmarkService.csv BookmarkService.ods
INFO:unoserver:Starting unoconverter.
INFO:unoserver:Opening BookmarkService.csv
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/unoserver/converter.py", line 173, in convert
    import_type = get_doc_type(document)
  File "/usr/local/lib/python3.9/site-packages/unoserver/converter.py", line 43, in get_doc_type
    if doc.supportsService(t):
AttributeError: 'NoneType' object has no attribute 'supportsService'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/unoconvert", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/unoserver/converter.py", line 276, in main
    result = converter.convert(
  File "/usr/local/lib/python3.9/site-packages/unoserver/converter.py", line 225, in convert
    document.close(True)
AttributeError: 'NoneType' object has no attribute 'close'

Maybe this is actually LibreOffice related?

# libreoffice --headless --convert-to ods BookmarkService.csv 
Error: source file could not be loaded

FWIW, unoconv also doesn't work:

# unoconv --verbose --output=BookmarkService.ods BookmarkService.csv 
Input file: BookmarkService.csv
unoconv: UnoException during import phase:
The document 'file:///opt/test/BookmarkService.csv' could not be opened.

Anything I can provide to help solving this?

Regards, Michael

dexterbg commented 1 year ago

D'oh… I relied on previously working automatic package installation dependency resolving. Apparently that doesn't work anymore with Alma 9, none of calc, writer etc. were installed, just pyuno & core + some aux packages.

Shortcut to install everything missing was dnf install -y libreoffice-filters. Now everything works, unoserver/unoconvert & unoconv.

Sorry & regards, Michael

regebro commented 1 year ago

Great!

regebro commented 1 year ago

@mbardelmeijer Does that solve it for you as well?

mbardelmeijer commented 1 year ago

Sorry for the delay, I haven't had the ability to put some additional time into this. If we're running into this again, I'll update the issue. Thanks!