将python模块导入XBMC以在插件中使用 [英] Importing a python module into XBMC for use within an addon

查看:559
本文介绍了将python模块导入XBMC以在插件中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将python模块(请求)导入XBMC.

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

我从github下载了该模块的zip文件,并将requests文件夹放入了我的XBMC插件的resources/lib文件夹中.

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

然后我将文件夹重命名为script.module.requests,并将导入请求添加到我的addon.py顶部

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

在我的XBMC.log中,我一直收到没有名为请求的模块的错误消息.

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

在这方面,我真是个菜鸟.

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

请帮助!

欢呼

推荐答案

首先,当您的文件夹名为script.module.requests时,import requests将不匹配

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

第二秒,您可能需要将 init 控制文件添加到资源和lib文件夹中,以便脚本可以找到模块(并执行import resources.lib.requests)或将文件夹添加到您的路径中,像这样:

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' ) ))

第三,有这个包: https://github.com/beenje/script.module.请求,然后将其添加到addon.xml文件中的require部分,但是,我还对XBMC在用户尚未安装包的情况下如何找到它感到困惑.

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...

这篇关于将python模块导入XBMC以在插件中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆