Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined symbol: libreofficekit_hook #12

Open
AnSharypov opened this issue Apr 6, 2017 · 21 comments
Open

undefined symbol: libreofficekit_hook #12

AnSharypov opened this issue Apr 6, 2017 · 21 comments

Comments

@AnSharypov
Copy link

AnSharypov commented Apr 6, 2017

  • 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
Copy link
Author

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

@alexmorozov
Copy link
Owner

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.

@AnSharypov
Copy link
Author

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
Copy link
Author

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

@alexmorozov
Copy link
Owner

@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?

@AnSharypov
Copy link
Author

AnSharypov commented Apr 10, 2017

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

@alexmorozov
Copy link
Owner

alexmorozov commented Apr 10, 2017

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

@AnSharypov
Copy link
Author

AnSharypov commented Apr 10, 2017

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

@alexmorozov
Copy link
Owner

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

@AnSharypov
Copy link
Author

@AnSharypov
Copy link
Author

AnSharypov commented Apr 11, 2017

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

@AnSharypov
Copy link
Author

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

@alexmorozov
Copy link
Owner

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
Copy link
Owner

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.

@AnSharypov
Copy link
Author

@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

@alexmorozov
Copy link
Owner

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

@AnSharypov
Copy link
Author

AnSharypov commented Apr 14, 2017

@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

@alexmorozov
Copy link
Owner

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.

@AnSharypov
Copy link
Author

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

@alexmorozov
Copy link
Owner

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

@AnSharypov
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants