[Solved] Including python modules in extensions

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
alois
Posts: 9
Joined: Mon Feb 22, 2016 2:23 pm

[Solved] Including python modules in extensions

Post by alois »

Hi,
How can I use my own python module in extensions?
When I include it in the addin package the standard python import fails ('no module named ..').
Most examples I found only use one python file and that containing multiple files use a complicated method to set the system path new but I couldn't figure out how this works.
I didn't find anything in the PyUNO wiki.
Last edited by Hagar Delest on Sat Apr 02, 2016 2:12 pm, edited 1 time in total.
Reason: tagged [Solved].
LibreOffice 5.0.2.2 on Windows 7
OlivierR
Posts: 38
Joined: Sun Jul 25, 2010 3:13 pm

Re: Including python modules in extensions

Post by OlivierR »

Just put your modules in the pythonpath folder of your extension.

In main.py:

Code: Select all

import mypackage
import mymodule
In your extension, it looks like this:

Code: Select all

main.py
/pythonpath/
/pythonpath/mypackage/
/pythonpath/mymodule.py
LibreOffice 6.4Windows 10
alois
Posts: 9
Joined: Mon Feb 22, 2016 2:23 pm

Re: Including python modules in extensions

Post by alois »

Hi,
Thanks a lot!
I knew it must be something easy.
LibreOffice 5.0.2.2 on Windows 7
Post Reply