Wednesday, 15 May 2013

eclipse - Import issues - is my Jython installed correctly? -



eclipse - Import issues - is my Jython installed correctly? -

i'm starting using jython. noted sys.path different when jython executed command line eclipse.

command line

tk:~$ jython jython 2.5.3 (2.5:c56500f08d34+, aug 13 2012, 14:48:36) [java hotspot(tm) server vm (oracle corporation)] on java1.7.0_10 type "help", "copyright", "credits" or "license" more information. >>> import sys >>> print sys.path ['', '/jproject/extras/2.5.3/lib', '__classpath__', '__pyclasspath__/', '/jproject/extras/2.5.3/lib/site-packages']

it's ok, can import there (import pdb, import csv, etc).

eclipse

i added jython.jar in eclipse java build path using "add jars" button. wrote simple java class (excerpt):

pythoninterpreter pi = new pythoninterpreter(); pi.exec("import sys"); pi.exec("print sys.path");

output:

['/jproject/projects/foobar/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/myproject/web-inf/lib/lib', '__classpath__', '__pyclasspath__/']

from python scripts created in java project can't import anything. importerror: no module named ...

so created file called .jython in home directory containing this:

python.path=/jproject/extras/2.5.3/lib:/jproject/extras/2.5.3/lib/site-packages

it seems prepare import issue. but, right way proceed?

i think don't have lastly step manually , installed jython badly.

looks have same issue described in question here:

the solution i've come workaround doesn't require actions user set python.path: added code sets python.path application work directory (user.path) before initializing jython environment.

eclipse jython pythonpath

No comments:

Post a Comment