0

XBMC has it's own python interpreter inside of it.

From this built in interpreter I need to run a script on the local machine python(i.e. the system python).

I call os.system("python myScript.py") but I get back the error in my system error:

ImportError: No module named site

I was hoping for ideas of guidance on how to troubleshoot this issue. Is it even possible to do? I'm thinking it has something to do with the pythonpath/pythonhome variable.

Seanny123
  • 8,776
  • 13
  • 68
  • 124
Dr. Chocolate
  • 2,043
  • 4
  • 25
  • 45
  • Is there a good reason, why you don't just import the script? That should also work, shouldn't it? – David Zwicker Nov 29 '13 at 13:50
  • you should probably indeed start looking at the import paths. – Thom Wiggers Nov 29 '13 at 13:53
  • Yes David! That would be the best solution BUT the script I'm calling (the Leap motion API) has to call a system level script itself. – Dr. Chocolate Nov 29 '13 at 14:20
  • Can you start Python from the commandline? – User Nov 29 '13 at 14:52
  • Yes! Python works great from command line. And I can even run my test script from the command line. I'm finding out my xbmc pythonpath is different from my system python path. So basically when I make a os.system it's not calling my local machine system python apparently. – Dr. Chocolate Nov 29 '13 at 15:20

1 Answers1

0

If you can locate your XBMC python interpreter's path (I would imagine it has the same python and is located inside xbmc/bin/ or something similar), you could run that python version instead of the default one when running python.

Your code should like so:

os.system(python_fullpath + " " script_fullpath)

Where both python_fullpath and script_fullpath, as the names imply, are full paths to those files.

Like, for example:

python_fullpath = "C:\Program Files\XBMC\bin\python.exe"
script_fullpath = "C:\Users\myuser\Desktop\myScript.py"
NirIzr
  • 3,131
  • 2
  • 30
  • 49