templated-docs icon indicating copy to clipboard operation
templated-docs copied to clipboard

undefined symbol: libreofficekit_hook

Open AnSharypov opened this issue 8 years ago • 21 comments

  • Templated-docs version: templated-docs==0.3.1
  • Python version: Python3.4
  • Operating System: Ubuntu 16.04

What I Did

  • Tried to update LO (current version 5.2.6)
  • output from locate libmergedlo.so is nothing
  • tried to change path in settings.py
Traceback (most recent call last):
  File "/usr/lib/python3.4/multiprocessing/process.py", line 254, in _bootstrap
    self.run()
  File "/usr/lib/python3.4/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.4/dist-packages/templated_docs/__init__.py", line 92, in _convert_subprocess
    with Office(lo_path) as lo:
  File "/usr/local/lib/python3.4/dist-packages/pylokit/lokit.py", line 110, in __init__
    self.lokit = lo.libreofficekit_hook(six.b(lo_path))
  File "/usr/local/lib/python3.4/dist-packages/cffi/api.py", line 866, in __getattr__
    make_accessor(name)
  File "/usr/local/lib/python3.4/dist-packages/cffi/api.py", line 862, in make_accessor
    accessors[name](name)
  File "/usr/local/lib/python3.4/dist-packages/cffi/api.py", line 792, in accessor_function
    value = backendlib.load_function(BType, name)
AttributeError: function/symbol 'libreofficekit_hook' not found in library '/usr/lib/libreoffice/program/libmergedlo.so': /usr/lib/libreoffice/program/libmergedlo.so: undefined symbol: libreofficekit_hook

AnSharypov avatar Apr 06 '17 20:04 AnSharypov

Guys, If someone can help with this problem, I would be sooo happy! What do I need to check? Which info can be useful? Just I have a struggle with this issue 2 days

AnSharypov avatar Apr 07 '17 07:04 AnSharypov

Hi, It almost certainly is related to the specific LibreOffice build not having LOKit built in. Could you try, for instance, to install a 5.1.1.3 LO version? It's specified in our Travis setup and tests run just fine on it.

I haven't used templated_docs on 16.04, another wild guess is that they removed LOKit in this version, but I'm highly doubtfull about that.

Please let me know if the above worked for you.

alexmorozov avatar Apr 07 '17 10:04 alexmorozov

I think it helped, at least I don't see this error. But now I have "504 Gateway Time-out" and Sentry/Supervisor log doesn't show some error at all. I'm not an expert in collecting of logs and I don't know the way how to find the reason of this error. What would you advise?

AnSharypov avatar Apr 09 '17 17:04 AnSharypov

Is there some way just to save doc file on server?

AnSharypov avatar Apr 09 '17 17:04 AnSharypov

@AnSharipov templated_docs creates a temporary file for every requested document, runs it through templating system, and then uses LibreOffice to convert it to another format. Finally, it returns the filename of a generated file. You could check if there are any files in your /tmp directory. Or is it empty altogether?

alexmorozov avatar Apr 10 '17 09:04 alexmorozov

@alexmorozov Thank you, there are .odt files! So, why don't they convert to pdf/docx?

AnSharypov avatar Apr 10 '17 10:04 AnSharypov

That is the question. ) Can you run your application in debug mode via ./manage.py runserver? Does it show any exceptions?

alexmorozov avatar Apr 10 '17 10:04 alexmorozov

@alexmorozov I ran ./manage.py runserver, but it looks like everything works fine. I mean all what I saw is:

(docks) root@zakazatdostavku:/opt/docs/Docs# python manage.py runserver 127.0.0.1:8096
Performing system checks...

System check identified some issues:

WARNINGS:
Docs.TKP.index: (fields.W122) 'max_length' is ignored when used with IntegerField
        HINT: Remove 'max_length' from field

System check identified 1 issue (0 silenced).
April 10, 2017 - 11:52:33
Django version 1.11, using settings 'Docs.settings'
Starting development server at http://127.0.0.1:8096/
Quit the server with CONTROL-C.

AnSharypov avatar Apr 10 '17 12:04 AnSharypov

@AnSharipov can you share an example of a document template that doesn't work?

alexmorozov avatar Apr 11 '17 14:04 alexmorozov

@alexmorozov https://yadi.sk/i/gphHz6VL3GsBfk

AnSharypov avatar Apr 11 '17 14:04 AnSharypov

@alexmorozov this is example of filled out doc https://yadi.sk/i/wIzhUP823GsCiD that I found in /tmp

AnSharypov avatar Apr 11 '17 14:04 AnSharypov

Maybe converting .odt to .pdf takes the time and that's why I'm getting 504 Gateway Time-out ?

AnSharypov avatar Apr 11 '17 15:04 AnSharypov

You may have the point! I've tried converting the template you sent me, and it took more than 11 seconds:

In [10]: %time fill_template('x.odt', {}, output_format='pdf')
CPU times: user 54.8 ms, sys: 22.1 ms, total: 76.9 ms
Wall time: 11.4 s
Out[10]: '/tmp/tmp9emybnhz.pdf'

So perhaps you should tune your nginx or whatever-you-use timeouts to a greater value. BTW, I'm not sure why it takes so long. You could try to remove some of the photos and check if the processing time decreases. Just to make sure what is the bottleneck here.

alexmorozov avatar Apr 12 '17 07:04 alexmorozov

I just noticed that the template itself is almost 5 megabytes. It may be useful then to scale down the pictures. As a comparison, try to convert the file to PDF using a standard desktop LibreOffice. I have a hunch it would take the similar amount of time.

alexmorozov avatar Apr 12 '17 07:04 alexmorozov

@alexmorozov I increased proxy_read_timeout from 30 to 300 and compressed .odt file. Now I'm getting: 502 Bad Gateway 2017/04/12 15:40:40 [error] 6865#0: *2688 upstream prematurely closed connection while reading response header from upstream The previous error was 504 Gateway Time-out

AnSharypov avatar Apr 12 '17 13:04 AnSharypov

@AnSharipov try to convert a file in ./manage.py shell (like I did a couple of comments above). If everything goes well, then the it's the server setup issue. If you get any errors while converting via command-line, please paste them in here.

alexmorozov avatar Apr 14 '17 09:04 alexmorozov

@alexmorozov I tried and got output:

>>> from templated_docs import fill_template
>>> from templated_docs.http import FileResponse
>>> context = {'ozo_name':'ozo_name','ozo_production':'ozo_production',}
>>> filename = fill_template('/opt/ecozon/Ecozon/Ecozon/templates/invoices/OzO_TKP.odt', context, output_format='PDF')

This process is not completing... I waited about 15 minutes. No errors, just a blinking cursor

AnSharypov avatar Apr 14 '17 09:04 AnSharypov

It almost certainly has to do with your LibreOffice configuration. I'd try another virtual machine / container. If you're feeling enthusiastic, you could also attach to the running process with strace and check what actually is going on.

alexmorozov avatar Apr 14 '17 10:04 alexmorozov

@alexmorozov My apologies, I only now mentioned that server is Ubuntu 14.04.5. Does it matter?

AnSharypov avatar Apr 14 '17 10:04 AnSharypov

It might not be the root cause, but something is definitelly messed up on the server.

alexmorozov avatar Apr 14 '17 10:04 alexmorozov

Hi @alexmorozov I deployed project on another server with Ubuntu 16.04, Python 3.5.2, templated-docs 0.3.1, Django 1.10.7, LO 5.1.0

Now, when I use python manage.py shell - I got .pdf file in /tmp But when I try to generate file on a web page I'm getting 502 error and don't have temp .pdf in /tmp

AnSharypov avatar May 06 '17 11:05 AnSharypov