|
From: Oti <oh...@gm...> - 2007-07-31 21:01:19
|
On 7/31/07, bo...@hu... <bo...@hu...> wrote:
> Hello-
> I have a simple java test where I'm using the PythonInterpreter to
> exec one statement: PythonInterpreter.exec("import myCPythonFile").
> This goes through with no problem and jython is able to create the
> myCPythonFile$py.class file.
>
> So I package this functionality into a jar. I included the
> standalone jython.jar, and an application.jar containing:
> MyText.class, myCPythonFile.py.
>
> I execute this packaged test and get the following error:
> ImportError: no module named myCPythonFile.
>
> My question is whether the error is caused by incorrect
> python.path'ing or because jython can't create the
> myCPythonFile$py.class? The idea is to distribute the application
> with uncompiled cpython files.
Bob,
I assume not the latter.
If you place your .py file inside a .jar, you have to set python.path
(by JVM start) or sys.path (from inside Jython) to the directory where
your *.py files are, e.g. application.jar/parent_dir_of_myPyFile.
As a shorthand, you could place myPyFile inside the /Lib folder of the
standalone jython.jar, as described here:
http://jython.extreme.st/talk/talk.html (search for Script Deployment)
The standalone jython.jar automatically adds jython.jar/Lib to sys.path.
HTH,
Oti.
|