Search code examples
androidpythonjythonmonkeyrunner

Trying to run simple monkeyrunner python script, 'importerror no module named os'


I have the android emulator/SDK installed on my computer, and I'm trying to run a simple python script, but it fails on the 'import os' line (which should be standard!)

Here's my script:

import os

print os.environ['PATH']

works fine when I run it against the actual python executable as

python test.py

but when I do

monkeyrunner.bat test.py

I get the error listed in the title of this question. I've uninstalled/reinstalled python several times, with no luck. Tried adding a PYTHONPATH ENV varaible, no luck. Set the python install dir to be in the PATH ENV variable. Kind of at my wits end, I think monkeyrunner runs on jython but I don't know if I can manage the jython install that comes with the SDK


Solution

  • The solution of this problem (and the problem itself explained) can be found at http://dtmilano.blogspot.ca/2013/05/monkeyrunner-importerror-no-module.html.

    Basically, you have to replace jython-2.5.3.jar by jython-standalone-2.5.3.jar, at least until Android SDK Tools Rev. 22.0.1 is out.