Importing a python module into XBMC for use within an addon

六眼飞鱼酱① 提交于 2019-12-11 11:33:52

问题


I'm trying to import the python module, requests, into XBMC.

I downloaded the zip of the module from github and placed the requests folder into the resources/lib folder of my XBMC addon.

I then renamed the folder to script.module.requests and added import requests to the top of my addon.py

I keep getting a no module named requests error in my XBMC.log.

I'm a total noob when it comes to this.

Please help!

Cheers


回答1:


first, import requests when your folder is called script.module.requests won't match

second, you probably need to add the init control files to the resources and lib folders so the script can find the module (and do a import resources.lib.requests) or add the folder to your path, like this:

sys.path.append (xbmc.translatePath( os.path.join( os.getcwd(), 'resources', 'lib' ) ))

third, there's this pack: https://github.com/beenje/script.module.requests which you would then just add it to the requires section in your addon.xml file, but then, I'm also puzzled on how XBMC would find it in case the user has not the pack already installed...



来源:https://stackoverflow.com/questions/14688278/importing-a-python-module-into-xbmc-for-use-within-an-addon

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!