error import python module xbmc


10 posts
by eccehomo » Sun Jan 27, 2013 9:59 pm
Hello,

I have the following problem: import of xbmc module fails with the following error message:

Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xbmc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named xbmc

Same problem with xbmcgui, xbmcaddon.
Same problem on raspbian and xbian.
Same problem as user or root.

I search all around the forums and do a lot of google searching... nowhere I found a solution.

I read that modules are visible only in the xbmc context. I guess that means that I have to loggon on a box where xbmc is up and running and scripting inside this box.

What I do :

Boot my raspberry with raspbian.
xbmc runs and works fine.
(I can play video/music with it. I can connect to the web interface from outside and ssh.)

I ssh to the box. OK
I can do shell commands etc.
I can succefully do http json rpc requests.

I fire python.
I've got the prompt.

>>> help('modules')

Please wait a moment while I gather a list of all available modules...

BaseHTTPServer argparse httplib sets
Bastion array ihooks setuptools
CDROM ast imageop sgmllib

(snip...)

_threading_local grp resource xml
_warnings gzip rexec xmllib
_weakref hashlib rfc822 xmlrpclib
_weakrefset heapq rlcompleter xxsubtype
abc hmac robotparser zipfile
aifc hotshot runpy zipimport
antigravity htmlentitydefs sched zlib
anydbm htmllib select

But :
>>> import xbmc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named xbmc


If anybody knows the solution, please help me.

Thanks a lot.
Posts: 6
Joined: Sun Jan 27, 2013 9:16 pm
by texy » Sun Jan 27, 2013 10:52 pm
I don't think xbmc is a python module - why do you think it is?
Did you see it in the list of modules?
I didn't - that why it cannot find it. ;)
Texy
"2.8inch TFT LCD + Touch screen" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=65566
50p goes to the Foundation ;-)
Forum Moderator
Forum Moderator
Posts: 2458
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by eccehomo » Sun Jan 27, 2013 11:05 pm
Thank for answering.

Please have a look at this HOW-TO:Write Python Scripts for XBMC

http://wiki.xbmc.org/index.php?title=HO ... s_for_XBMC

In the beginning...

1.4 the real work begins

There are two specific libraries for Python only available in XBMC: xbmc and xbmcgui. They are dedicated to the user interface, and keypad management.
Python code will be colored in blue I will only talk about scripts including a graphical interface, as the console ones work without xbmc libraries.
1.4.1 Window
So the first thing to do is to import libraries
import xbmc, xbmcgui

But you right it's not exactly modules... I don't know why I called this modules... I should say libraries.
Posts: 6
Joined: Sun Jan 27, 2013 9:16 pm
by eccehomo » Sun Jan 27, 2013 11:30 pm
Oups...

Please read "raspbmc" instead of "raspbian" in my first post...

Sorry for the confusing :oops:
Posts: 6
Joined: Sun Jan 27, 2013 9:16 pm
by -rst- » Mon Jan 28, 2013 3:30 pm
No idea about XBMC, but quick googling turned up this: http://wiki.xbmc.org/index.php?title=Python_development 'XBMC includes a built-in Python interpreter that allows users to develop add-ons', so I assume you have to run your scripts under that interpreter NOT under the 2.7 'stand-alone' Python as it looks like from your post.

Maybe this helps http://wiki.xbmc.org/index.php?title=HO ... asic_Steps
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'
Posts: 903
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland
by eccehomo » Mon Jan 28, 2013 8:09 pm
Hi Rst,

Thanks for your suggestion. I knew this HOW-TO and many others. You guess that was my first step... (RTFM is my philosophy ;)

But no one says how to start or how to access to this built-in interpreter... Here lies the conundrum :)

I begin to think that you have to ask XBMC application itself to run the script (at startup for instance or by a menu inside the app.)

It's odd. It's not an easy way to test and debug...
Posts: 6
Joined: Sun Jan 27, 2013 9:16 pm
by -rst- » Mon Jan 28, 2013 9:54 pm
Well, shows that I didn't bother to read the docs in enough detail (then again I haven't touched XBMC yet...). Would have thought them mentioning how to actually develop plugin scripts ...and they ask forgiveness from experienced devs for the manual being dumbed down - yet another fine open source project/component :roll:

Google finds some stuff with 'how to debug xbmc plugin' - maybe you tried that already as well...
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'
Posts: 903
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland
by eccehomo » Mon Jan 28, 2013 11:12 pm
Yes you right, I already read a lot of stuff about this problem before posting on forums. It's pretty crazy that no where I can't find a clear answer about this point.

IMHO, XBMC HOW TO for beginners forgets simply the beginning which is really specific here.

Yesterday I found a forum where I was able to download librairies xbmc and xbmcgui allowing to script with the standard python shell if you add them as source to your project... but it's a work around not the solution of the enigma.

My mind doesn't leave me in peace: it asks the answer...

But now I quite convinced that the fact is that there no access to an interpreter with a shell but you have to execute script from inside the XBMC app via menus as add-on, ect.

I would like that an XBMC script/add-on developper give me indications about the IDE I could use. Really it's not obvious for me. I'm not familiar with python nor XBMC and this situation where you are looking for the interpreter is not usual for me.

But XBMC is a wonderfull framework for artistic video projects based on raspberry pi (HD video h264 runs perfectly). So I continue my investigations :)
Posts: 6
Joined: Sun Jan 27, 2013 9:16 pm
by -rst- » Tue Jan 29, 2013 11:20 am
Glad to see someone taking the 'RTFM' trouble before posting ...not all do ;)

Yea, that documentation is lacking a vital bit and it is a surprise no-one has filled that gap. Might be worth registering on their forum and wiki to start a discussion - my ex-team-lead always used to say that 'best person to update the docs/wiki is the one who finds an issue with them' and I have to agree :)
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'
Posts: 903
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland
by eccehomo » Tue Jan 29, 2013 12:14 pm
Hi,

I've posted my question on both the raspberry pi and xbmc forum and yesterday evening I've got an answer from an xbmc coder :)

For your information: http://forum.xbmc.org/showthread.php?tid=153612

There is a link to a doc that explains the concept and give pratical informations in order to script inside XBMC.

In short: "The modules are only available to the Python Addon engine inside XBMC", so you have to run the script inside XBMC via the menu (or at startup, ect.)

I'm not enough skill to update the doc. But may be this thread will help some one in the future.

Thanks for helping and best regards
Posts: 6
Joined: Sun Jan 27, 2013 9:16 pm