问题
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