|
From: <bc...@wo...> - 2002-01-21 23:54:59
|
[Frank Cohen] >Hi all: Thanks so much for all the hard work being done on Jython. I think >Jython is a terrific project. > >I am embedding Jython into the next version of PushToTest Load - a framework >for writing intelligent test agents to test Web services for scalability and >performance. Details are at: http://www.pushtotest.com/ptt/wiki/LoadPreview > >Load will be implemented as a NetBeans module (http://www.netbeans.org.) The >module instantiates an instance of Jython and passes it a script to run. >Here's the code I'm using: > > PythonInterpreter interp = new PythonInterpreter(); > > try > { > interp.execfile( FileUtil.toFile(theScriptFile).getPath() ); > } > catch ( PyException e ) > { > System.out.println( "1=" + e.fillInStackTrace() ); > System.out.println( "2=" + e.getLocalizedMessage() ); > System.out.println( "3=" + e.getMessage() ); > System.out.println( "e.traceback.tb_lineno = " + >e.traceback.tb_lineno ); > System.out.println( "e.traceback.tb_frame = " + >e.traceback.tb_frame ); > System.out.println( "e.traceback.tb_next = " + >e.traceback.tb_next ); > > } > >This works well except for importing Jython libraries. When I run this >script: > >import random >print "Hi its me here at test.py" >i=10 >print i >print random.random() > >I get this exception: > >Traceback (innermost last): > File "<string>", line 1, in ? >ImportError: no module named random It sounds like FAQ 6.2: http://www.jython.org/cgi-bin/faqw.py?req=show&file=faq06.002.htp The standard python modules must still be loaded from the filesystem using the directories in sys.path. For debugging, try to adding these statements before importing "random": import sys print sys.path regards, finn |