Using the Requests Library
#1
I added the Requests library to python on my computer, and everything is working fine, but when I try the script on another computer it doesn't work.
I know i'm supposed to include 'requests' in the lib folder in my add-on, but i just don't know how

right now I have the requests folder in c:\python33\lib
i would assume i would just put the requests folder in "my.addon\resources\lib\(requests folder here)"

but I don't know how I would call it.. right now i'm just using "import requests"

any help would be greatly appreciated.

here is the source: https://github.com/Karrade/xbmc-repo/tre....tv.promos
Reply
#2
you'd first need to append your resources/lib folder to the python path:

Code:
__cwd__ = xbmc.translatePath(__addon__.getAddonInfo('path')).decode("utf-8")
BASE_RESOURCE_PATH = os.path.join(__cwd__, 'resources', 'lib')
sys.path.append(BASE_RESOURCE_PATH)
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
someone way smarter than me just mentioned the python request module
is already available through our addon repo.

so if you're planning to submit you addon to the repo, you should use that instead.
in that case, you simple add it to the requirements in your addon.xml:
Code:
<requires>
    <import addon="script.module.requests" version="1.1.0"/>
</requires>
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#4
thank you very much!. im new at this and that helped alot.
Reply
#5
(2013-08-21, 01:06)ronie Wrote: you'd first need to append your resources/lib folder to the python path:

Code:
__cwd__ = xbmc.translatePath(__addon__.getAddonInfo('path')).decode("utf-8")
BASE_RESOURCE_PATH = os.path.join(__cwd__, 'resources', 'lib')
sys.path.append(BASE_RESOURCE_PATH)

BTW, are three any potential issues if I use:
PHP Code:
__cwd__ os.path.dirname(__file__
instead of
PHP Code:
__cwd__ xbmc.translatePath(__addon__.getAddonInfo('path')).decode('utf-8'
?
Reply
#6
(2013-08-22, 13:00)Roman_V_M Wrote: BTW, are three any potential issues if I use:
PHP Code:
__cwd__ os.path.dirname(__file__
instead of
PHP Code:
__cwd__ xbmc.translatePath(__addon__.getAddonInfo('path')).decode('utf-8'
?

Yes, using "os.path.dirname(__file__)" will not always return what you want ;-)
I could tell you some examples but there is also the official rule that add-ons are not allowed to use it and any explanation wouldn't help you Wink
My GitHub. My Add-ons:
Image
Reply

Logout Mark Read Team Forum Stats Members Help
Using the Requests Library0