Run a a script from system python interpreter from an external python interpreter

799 views Asked by At

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.

1

There are 1 answers

0
NirIzr On

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"