How can I use Libreoffice embedded python in a Venv from Pycharm

Viewed 23

I am trying to use Pycharm to develop Libreoffice python Macro with in the virtual environment with not a lot of success. You'll find below a few things I have tried with the differnt errors I have had so far. I welcome any answers on the errors below as well as alternate solutions.

first try : set up directly the venv environment

As when you work with Libreoffice, you need to use the embedded python integrator, the first attempt is when defining the python integrator in pycharm, I reference this embedded interpreter (located somewhere in Program Files\Libreoffice\program` on my windows machine, I click the new venv box in pycharm and get the following error :

Error: standard python 'venv' module not found

So it seems venv is not packaged with the Libreoffice embedded python environment. Is there a way to add it?

Second try : inject embedded environment inside a precreated venv

What I did here was to create the Venv in pycharm using a standard python version aligned with the one libreoffice uses (here 3.8.10). Once the venv is succesfully created, I manually change the path to the python based interpretor to the proper libreoffice one.

I also update the pythonpath in pycharm for this venv to include Files\Libreoffice\program\ so that we can find some preinstalled modules suitable for Libreoffice, in particular uno.py.

This looks a little better, I can launch a libreoffice instance, but when I actually want to do stuff inside this instance from python, I get the following error loading component library </mergedlo.dll> failed

This mergedlo.dll file is in a directory referenced in the python path for this venv.

What configuration did I miss here?

0 Answers
Related