Import python module

classic Classic list List threaded Threaded
1 message Options
jan-3 jan-3
Reply | Threaded
Open this post in threaded view
|

Import python module

Hello LibO devs,

I have problems importing a python module.

Context: The main python script is in the folder [my home
directory].config/libreoffice/4/user/Scripts/python/somesubfolder/src
named "Test_embed.py"
Also in this folder, I placed another python file (qdahelpers.py) which
I want to import into Test_embed.py, using "import qdahelpers"

System: Ubuntu 16.04 with LO 5.3

What happens: The main script appears in the Tools/Macros/Run Macro…
dialog (the script to be imported, too). If I run the main Test_embed
via the dialog I get the following message:


> A Scripting Framework error occurred while running the Python script vnd.sun.star.script:myDocEmbed|src|Test_embed.py$Run_Test_embed?language=Python&location=user.
>
> Message: <class 'ImportError'>: No module named 'qdahelpers'
>   File "/usr/lib/libreoffice/program/pythonscript.py", line 998, in getScript
>     mod = self.provCtx.getModuleByUrl( fileUri )

Is it not possible to import python files in this way when using them in
Libreoffice? Or is the file executed in another context than the folder
it resides in? If yes, is there a way how I can import nevertheless?

Kind Regards,
 Jan
_______________________________________________
LibreOffice mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/libreoffice