7

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?

2 Answers2

8

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.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
1

Assuming you have the proper modules installed: They aren't in your system path. You can check your system path manually to see if the directory is there by doing

import sys
print sys.path

You can append to sys.path as you would any list, but it's probably better to modify it via your OS, rather than on the fly appending. (which is temporary, sys.path reverts to its original state after the end of the script in python)

seth
  • 1,778
  • 16
  • 17
  • I got this log: ['D:\\MonkeyRunnerTest\\test', 'C:\\Python33\\lib\\site-packages\\distribute-0.6.27-py3.3.egg', 'C:\\android-sdk\\sdk\\tools\\lib\\monkeyrunner.jar', 'D:\\MonkeyRunnerTest', 'C:\\android-sdk\\sdk\\tools\\lib', 'C:\\Windows\\system32\\python33.zip', 'C:\\Python33\\DLLs', 'C:\\Python33\\lib', 'C:\\Python33', 'C:\\Python33\\lib\\site-packages', 'C:\\Python33\\lib\\site-packages\\setuptools-0.6c11-py3.3.egg-info'] Looks like monkeyrunner path was added in proper way – Nathaniele Eldritch Jul 17 '13 at 06:38