Using jython, I used a Python file in my Java code like below. package jython_connect;
import org.python.core.*;
import org.python.util.PythonInterpreter;
public class jython_test1 {
private static PythonInterpreter interpreter;
public static void main(String[] args) {
interpreter = new PythonInterpreter();
interpreter.execfile("test.py");
PyObject str = interpreter.eval("test(7)");
System.out.println(str);
}
}
And in test.py include python library like numpy. An import error occurs as shown below.
ImportError: No module named numpy
I am using Jython 2.7.1, and I ran the below command but it failed.
jython -m pip install numy
How can I use the Python library in Java?