ImportError: No module named 'com.android'

Nathaniele Eldritch picture Nathaniele Eldritch · Jul 17, 2013 · Viewed 7.1k times · Source

I'm writing a simple test for Android app and it fails while trying to connect my device with this log:

Traceback (most recent call last):   File "D:/MonkeyRunnerTest/test/LaunchTest.py", line 3, in <module>
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice ImportError: No module named 'com'

I use Pycharm 2.7.3, Python 3.3.2, juthon-standalone-2.5.3. I've tried to launch my test project on Eclipse with PyDev and Intellij Idea with Python plug-in, but with the same result. Also I've added environment variable PYTHONPATH containing the path to monkeyrunner and jython source to my operation system (Windows 7), it didn't help.

Any suggestions for this issue?

Answer

Diego Torres Milano picture Diego Torres Milano · Jul 18, 2013

You should only use monkeyrunner interpreter to run monkeyrunner scripts. Forget about python, jython, etc.

From you command line try:

monkeyrunner LaunchTest.py

and it will work.

You can find some instructions to use monkeyrunner with Eclipse+Pydev. See the updates at the bottom of the page.