PySystemState is the sys module.  You need to initialize sys.path.  You can do it
by invoking python code in the interpreter, or by calling methods of PySystemState
from Java.  I do it like this:

      String initScript =
        "import sys\n" +
        "sys.path.insert(0,'"+home+"')\n" +
        "sys.path.append('"+jarFilePath+"')\n" +


On 8/1/2014 12:39 PM, Parisa Zahedi wrote:
I am trying to execute a python method from eclipse using jython. I managed to run it with following code:

                         System.getProperties(), new String[0]); 
PythonInterpreter interpreter = new PythonInterpreter();

My problem is when I import another python script which exists even in the same directory with For example, when I add:

from food import Pizza

to, it starts to complain that cannot import. ImportError..

I found some questions about importing python libaries like os, but in my case this is not an issue.

I tried to make the folder as a package, add etc but it failed.  I saw  some people use PySystemState, but I think it is for jython modules not user python scripts. if this is the solution please give me a simple example.

Could you please help me with that problem.

Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.

Jython-users mailing list