Similar question have been asked here an year ago but no answer yet.
Im running a Python
script via Java
and I'm getting
ImportError: No module named numpy in <script> at line number 1
This is my code:
public void runScript(String filePath) throws Exception {
StringWriter writer = new StringWriter();
ScriptContext context = new SimpleScriptContext();
context.setWriter(writer);
Options.importSite = false;
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("python");
engine.eval(new FileReader(filePath), context);
System.out.println(writer);
}
How do I run script with it's imports?
Of course all the required installations have been installed (with pip install) and that the code runs perfectly when I run it not through java.