[Solved] Including python modules in extensions

Creating a macro - Writing a Script - Using the API

[Solved] Including python modules in extensions

Postby alois » Tue Mar 29, 2016 1:16 pm

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
alois
 
Posts: 9
Joined: Mon Feb 22, 2016 2:23 pm

Re: Including python modules in extensions

Postby OlivierR » Wed Mar 30, 2016 11:42 pm

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

In main.py:
Code: Select all   Expand viewCollapse view
import mypackage
import mymodule


In your extension, it looks like this:
Code: Select all   Expand viewCollapse view
main.py
/pythonpath/
/pythonpath/mypackage/
/pythonpath/mymodule.py
LibreOffice 6.4Windows 10
OlivierR
 
Posts: 38
Joined: Sun Jul 25, 2010 3:13 pm

Re: Including python modules in extensions

Postby alois » Fri Apr 01, 2016 8:43 am

Hi,
Thanks a lot!
I knew it must be something easy.
LibreOffice 5.0.2.2 on Windows 7
alois
 
Posts: 9
Joined: Mon Feb 22, 2016 2:23 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 3 guests