solved: createInstanceWithContext: Binary URP bridge disposed during call

I decided to experiment with OpenOffice automation from Python, found the official PyUNO wiki, followed the "a must read" link PyUNO bridge and tried the proposed hello-world program "". As it was feared, nothing worked immediately. The error was:

Traceback (most recent call last):
  File "", line 19, in 
    desktop = smgr.createInstanceWithContext( "",ctx)
__main__.RuntimeException: Binary URP bridge disposed during call

The search in Internet was not helpful. Instead, it added confusion.

Fortunately, there was a mention of the tool unoconv, which converts between any document format that OpenOffice understands. I tried it to test if it would fail with the same problem. But it worked perfect.

I opened the source code, found that unoconv does a lot of initialization of the environment and decided to reproduce it. I dumped the environment inside the Convertor::__init__ method:

for i in os.environ.iteritems():
  print '%s=%s' % i

This helped to construct my own initialization:

export UNO_PATH=/usr/lib/libreoffice/program
export LD_LIBRARY_PATH=/usr/lib/libreoffice/program:/usr/lib/libreoffice/ure/lib
export PYTHONPATH=/usr/lib/libreoffice/program:$PYTHONPATH

Now "" works as promised.

Categories: publishing