A (hopefully) easy question about getting started
#1
So I've been learning python for a couple months now. And I'd like to learn how to write addons. There's lots of good tutorials out there, so that's not my issue.

My issue is importing the modules. ie: import xbmc. Usually I'd just install it with pip, but that of course doesn't work.

What am I missing here?
Reply
#2
Hi. I too recently started with this. I just copied an existing addon and hack away in notepad.. Whatis important is the matching addon.xml file that tells kodi how to use your scriot.

Have a look in the addon folder for lots of scripts and examples. And in the wiki.
Reply
#3
The xbmc modules are built in to Kodi, but are only available to scripts that are called within Kodi, not as stand-alone ones.

You can use the kodi-send command from the command line to test scripts that way:

Code:
kodi-send --action='RunScript("/path/to/script.py")'

but longer term if they're packaged up as an add-on then Kodi can run them at start-up via the addon.xml as @Torben says and the modules should be available for import directly then as normal.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#4
Ok, so writing scripts thru an IDE (I use PyCharm), you just have to deal with it showing errors then?

Also, what about debugging then? How do you step thru code to help find any errors?

And thanks for the answers, very helpful.
Reply
#5
Errors should show up in the log file (debug log (wiki) although you don't need to have debug active).

You can view that either real-time (with the log viewer app or directly) or just look at it via SMB or similar (you can find the logs location detailed here, depending on which platform you're running). There's kodi.log for the current run, or kodi.log.old for the previous one (before the last reboot).

There are also wiki pages on Python development (wiki) which may be worth a read if you haven't already.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply

Logout Mark Read Team Forum Stats Members Help
A (hopefully) easy question about getting started0