Wednesday, August 29, 2012

monkeyrunner: setting Eclipse PyDev interpreter

There have been some popular posts in this blog describing the use of Eclipse, PyDev and monkeyrunner. However, I have received a lot of questions regarding the definition of the interpreter and perhaps it requires a little deep explanation.

Even though monkeyrunner is a Jython interpreter, to successfully use it from PyDev you have to identify it as plain Python.

This screenshot shows the definition of the interpreter which coincidentally, we called monkeyrunner.


Following these steps you would have no problems using monkeyrunner from PyDev.
Hope this helps.

12 comments:

Ashwani Kumar said...

I am trying to do this on Ubuntu but it fails with following error:
See error log for details.
A jar cannot be used in order to get the info for the python interpreter.

Any Idea how to resolve this issue???

Smitha said...

Hi,

Back to you for help/info.

Wanted to confirst if Monkeyrunner support is available for Jelly bean?

Thanks,
Smitha

Diego Torres Milano said...

@Smitha,
Yes, monkeyrunner works with Jelly Bean.

Florin Buda said...

man !! I own you a beer !!

Zellman said...

Diego,

I have set ANDROID_VIEW_CLIENT_HOME and sys.path includes '/Users/zellman/Development/dtmilano/AndroidViewClient/AndroidViewClient/src', but I get the following error when trying to run in Eclipse:
from com.dtmilano.android.viewclient import ViewClient #@UnresolvedImport
ImportError: No module named dtmilano

Any ideas?

Zellman said...

For the record, the same script works when run from the command line.

Diego Torres Milano said...

@Zellman,
Did you see:
https://plus.google.com/u/0/b/111731764904697052166/111731764904697052166/posts

Zellman said...

Yeah, I read that article, which is why I chose PyDev.

I imported AndroidViewClient as a project in Eclipse so I could add it as a project reference and include it as a source folder in the pydev properties for my test project. However, it won't take. Every time I close the properties window it reverts to tests/src instead of AndroidViewClient/src.

I also tried to include the AndroidViewClient src folder as an External Library, but still get the "No module named dtmilano" error.

Diego Torres Milano said...

@Zellman,
I'm starting to understand your problem.
Let's start with something simpler:

Can you run from Eclipse some of the examples in AndroidViewClient, let's say dump.py?

Zellman said...

@Diego, sorry for the delay in response, I got distracted by some other things for a while.

Yes, dump.py runs fine in Eclipse. What do you think I should try next?

Thanks,
Andrew

Zellman said...

Interesting...

If I run dump.py from within the examples directory of AndroidViewClient, then it works fine, but if I copy the file out to my other project, it doesn't. Is com.dtmilano... dependent on the working directory being set to AndroidViewClient? I ask because the working directory seems to be the only difference between these two Run Configurations.

Zellman said...

Even more interesting...

If I change the Run Configuration to have AndroidViewClient as the Project, but my script as the Main Module, then it runs fine. Even if I change the working directory to also be my project's home directory.

----------------------------------------------

I was able to delete all .pyclass files, reset all configurations on both the AVC project and my own, and now I'm able to run it just fine. Don't know what the issue was, though