Importing my user defined modules

Good Morning,

I have made a set of python modules (using APSO) in the “My Macros” section. I would like to use them in my base application. The python code within my base file should be able to import my modules. however i get the error:

<class 'ModuleNotFoundError'>: No module named 'ModuleDbConnections'
  File "D:\Program Files\LibreOffice\App\libreoffice\program\pythonscript.py", line 1057, in getScript
    mod = self.provCtx.getModuleByUrl( fileUri )
  File "D:\Program Files\LibreOffice\App\libreoffice\program\pythonscript.py", line 494, in getModuleByUrl
    exec(code, entry.module.__dict__)
  File "vnd.sun.star.tdoc:/728267628/Scripts/python/LbryCuttingDescriptions/ModuleCuttingDescriptions.py", line 8, in <module>
  File "D:\Program Files\LibreOffice\App\libreoffice\program\uno.py", line 346, in _uno_import
    return _builtin_import(name, *optargs, **kwargs)

More context is needed: most desirable is some simple action sequence allowing to repro the problem from scratch on any system. But at least, what is in the respective import directive in your python code within your base? Or the URL in the call to getModuleByUrl / getScript.
vnd.sun.star.tdoc:/728267628/... looks odd. The vnd.sun.star.tdoc: means document context; it’s unexpected that it is followed by only a single slash. But maybe it’s OK, since it seemingly works…
The D:\Program Files\LibreOffice\App\libreoffice\program path is unusual, but likely you have some custom preference, making the actual LibreOffice installation path nested under additional LibreOffice\App.

IMHO there was a discussion (recently?) where they mentioned APSO to hide pythonpath. This would prevent using the internal use of modules in python without special counter-measures.
.
Check the following as explanation, there are also some work-arounds (above the linked entry):

1 Like

Thank you. I will check on that.