Kodi Community Forum

Full Version: Cant import xbmcgui
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I began xbmc scripting & was following AlexPoet's tutorials.
I couldnt import xbmcgui.
It said that xbmcgui needs another import called Image (on line 3).
I searched in my python Lib and it wasnt there either (Python 2.6).
Where can i get this from?
Welcome Wink

It's shipped with xbmc. Make sure you've installed XBMC and all its dependencies properly. If you need help from other python coders you should consider posting a full debug log (use pastebin or similar service) and example scripts to reproduce the error.
if you are trying to run the code outside of xbmc, then you need PIL (python image lib) but that's so outdated.

Use xbmc to run code in and an editor of your choice Smile
@grass
You need PIL for Python 2.4 (that's the version XBMC is using); see below - you need the source kit archive, extract the PIL directory close to your script/plugin (for plugins usually the additional libraries are held in plugin_name\resources\lib folder).

http://www.pythonware.com/products/pil/

PS: You should use Python Scripts/Plugins Development forum to ask this type of question...
I am able to get started with notepad as I can test output on xbmc. The problem occurs during errors, i cant see what they are nor their stacktraces.

IDLE is missing half the files that came with xbmc, hence I cant really test on that either. How do people generally debug their XBMC scripts?
Since you mentioned Windows, see xbmc.log at %APPDATA%\XBMC\xbmc.log - I would recommend using Notepad++ as it can reload the file upon change. That's where you get your stack trace and errors.

What is IDLE?
IDLE, that default program which came with python i used it to check syntax, etc.
Again, XBMC is delivered with Python 2.4, keep that in mind when coding.

Personally I use Eclipse with PyDev plugin (http://pydev.sourceforge.net/), you could try setting that up and see how does it work for you. Otherwise the notepad and xbmc.log method is pretty much the basic way to developer XBMC addons.

And last, something I meant to say earlier, it's not xbmcgui that depends on Image (PIL), it's the code in your script referencing that...
Definetly errors showed up & the auto-reload was useful, but not stacktraces in that file.
Ok then, back to basics? What version of XBMC are you using? Hope you use latest version (9.04) and if so, the second question is when you installed it where did you choose to place the addons? Was it in %APPDATA%\xbmc or C:\Program Files\XBMC? check for xbmc.log in both places.

Second, if you want to post your code somewhere on the web (if a single file, pastebin.com will do, if a zip file I don't know, mediafire.com?) we can have a look as well and see what's wrong with it...
I have the latest xbmc

The code is from the tutorials mostly,
http://pastebin.com/m56a38c61

Stacktraces work with pydev!!! Smile (But i get an annoying popup to buy it Angry)

http://pastebin.com/m79745dec

I think i know why the error is coming (maybe 'coz python cant use all the image files that xbmc can.) but i dunno how to fix it,

Debug logs also showed up, though at that time i was looking for stacktraces & hence didn't pay too much attention to them
Ok, maybe I didn't make myself clear enough... I use Eclipse + PyDev to write the code and then test it from WITHIN XBMC, then it will produce the errors in xbmc.log... Yes, PydDev has an ocasional popup, but I think you can simply ignore it... ah, or buy it :-)

Your addon is a script, so you need to put that in %APPDATA%\XBMC\scripts and you can run it from the Scripts menu. Just tried it and it works fine, I got the two labels no problems.

Before you spend too much time writing scripts, I would recommend having a look at plugins as well (see mine below in signature) - it makes it easier to develop addons as you don't have to build all that UI infrastructure, care about screen resolutions, skins etc...
Dan Dare Wrote:Personally I use Eclipse with PyDev plugin (http://pydev.sourceforge.net/), you could try setting that up and see how does it work for you.
Hey, me too! Laugh
It is a very good IDE for coding Python script.
true Big Grin who wouldn't like Python syntax checking / syntax highlight, tab editing, integrated file manager, SVN client, Ant support and so on, all that in one place...

I used to use Notepad++ to write XBMC addons, but since we've been using Eclipse for J2EE at work for a few years now I looked for and found the plugin from the good men of PyDev. That was very helpful with the little annoying mistakes and all that frustration that comes with beginings...