1

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?

6

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.