Why importing MonkeyRunner into Python script fails in Windows?

I created a file foo.py and copy-pasted code from the MonkeyRunner docs. The following error appears when compiling the sample code in cmd line:

Traceback (most recent call last):
  File "foo.py", line 2, in 
    from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
ImportError: No module named com.android.monkeyrunner


The Android tools folder has monkeyrunner.jar... and I fail to understand how to tell Python to import classes from it.


Follow-up

I found out the error came because I didn't have the latest Android tools (16).

  1. Update to newest tools (16) & platform (15) first
  2. Add android-sdk\tools into path
  3. Put foo.py into android-sdk\tools folder (it doesn't seem to work anywhere else)
  4. Switch usb debugging on
  5. Attach phone to PC
  6. Type "monkeyrunner foo.py"
Edit
Report