Hi I am new to python development. I am trying to execute the code given at http://dtmilano.blogspot.in/2012/02/monkeyrunner-interacting-with-views.html but when ever i am trying to execute the code i get following error:
Traceback (most recent call last):
File "C:\Users\gur31265\workspace\MonkeyRunnerForSmartRecorder\com\test\Runner.py", line 23, in <module>
from com.dtmilano.android.viewclient import ViewClient
ImportError: No module named dtmilano
I am using eclipse with PyDev and Jython 2.5.3. I had also configured Python 32 on eclipse running on Windows 7 machine. Other Python scripts are running fine but i don't know why code given on dtmilano's blog is causing this error. I had also installed AndroidViewClient and set the ANDROID_VIEW_CLIENT_HOME in system path. Please help.
You can find a detailed explanation about how to use PYTHONPATH
and ANDROID_VIEW_CLIENT_HOME
environment variables from Eclipse and PyDev and also from command line at http://dtmilano.blogspot.ca/2012/09/monkeyrunner-importing-from-pythonpath.html.
Briefly:
#!/usr/bin/env monkeyrunner
import re
import sys
import os
import java
# This must be imported before MonkeyRunner and MonkeyDevice,
# otherwise the import fails.
# PyDev sets PYTHONPATH, use it
try:
for p in os.environ['PYTHONPATH'].split(':'):
if not p in sys.path:
sys.path.append(p)
except:
pass
try:
sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
pass
from com.dtmilano.android.viewclient import ViewClient, View
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice