python - Importing a module in resources/ into an XBMC plugin -


i'm working on xbmc plugin requires few python modules not available via requires tag in addon.xml (they not in xbmc repository far i'm aware). documentation plugin development seems indicate can adding module(s) resources/lib/ subdirectory of plugin directory.

i've done , when testing in xbmc import error trying import module because cannot found.

i've read other question found on regarding topic entitled importing python module xbmc use within addon proposed solution there, of adding module directory path before importing, doesn't work me either. same import error.

in fact don't think answer correct because os.getcwd() in xbmc not return plugin directory path when called within plugin; concatenating path gives /resources/lib answer suggests won't yield valid path. modified example use getaddoninfo find plugin path addon object via xbmcaddon module , added path concatenated /resources/lib still did not work.

putting modules root of plugin directory doesn't work. haven't been able find specific documentation how correctly beyond initial tutorial saying should add resources/lib subdirectory.

so know how or have example of being done in xbmc plugin?

figured out mistake. wasn't paying attention path adding. adding addon profile directory sys.path using getaddoninfo('profile') when should have been using getaddoninfo('path')

for future reference, if want add subdirectory of addon path, did:

import xbmcaddon import os ...  my_addon = xbmcaddon.addon('plugin.video.my_plugin') addon_dir = xbmc.translatepath( my_addon.getaddoninfo('path') )  sys.path.append(os.path.join( addon_dir, 'resources', 'lib' ) )  import <whatever modules want> 

i guess that's yet lesson in paying close attention content of error message.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -