Im trying to use java to run a python function through jython.jar. I'm using a python module that is downloaded from web which needs python 2.6 or higher. I'm pretty sure that my python is version 2.7.2. However, when I try to run the java program, it continues to report python 2.5 detected. How can I resolve this?
My code is:
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
...
//cmd
String command = "\"xml\\" + name2 + "\"";
PythonInterpreter python = new PythonInterpreter(null, new PySystemState());
PySystemState sys = Py.getSystemState();
sys.path.append(new PyString("C:\\Python27\\Lib\\site-packages"));
python.execfile("work1.py");
}
}
}
}
And the error is:
Exception in thread "main" Traceback (most recent call last): File "work1.py", line 8, in <module>
import networkx as nx File "C:\Python27\Lib\site-packages\networkx\__init__.py", line 39, in <module>
raise ImportError(m % sys.version_info[:2]) ImportError: Python version 2.6 or later is required for NetworkX (2.5 detected). Java Result: 1