I am trying to use java to run a python function through jython.jar. I am using a python module that downloads from the internet, which requires python 2.6 or higher. I am sure my python is version 2.7.2. However, when I try to run a java program, it continues to report python 2.5 detection. How can i solve this?
My code is:
public class Main {
public static void main(String[] args) {
...
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:
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
source
share