I am trying to create a maven java project which calls python script that have imports from 3rd party modules like pandas. I have installed Python3 and installed pandas using pip command. I am using vsCode as IDE and has windows 10 OS.
Im attaching the sample code i used.
App.java
public static void main(String[] args){
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.execfile("./src/main/resources/hello.py");
PyFunction function = interpreter.get("get_data", PyFunction.class);
PyObject obj = function.__call__();
System.out.println(obj);
hello.py
import pandas as pd
def get_data():
data = {'name': ['John', 'Emily'],
'age': [30, 40]}
df = pd.DataFrame(data)
return df
pom.xml
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-standalone</artifactId>
<version>2.7.2</version>
</dependency>
The error I am getting is ImportError: No module named pandas. What I am expecting is that the program is not able to find the modules from python lib.