Can someone explain why I get no output? The java code outputs errors in the python script just fine, but not the DataFrame that returns when the Python code is successful. Im deploying on a Python 3.4 environment with a python script that looks like this called through Java:
d = {'one' : pd.Series([1., 2., 3.], index=['a', 'b', 'c']),
'two' : pd.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd'])}
df = pd.DataFrame(d)
df
My Java code calling the python:
private static String executePythonCorrelations() {
String dir=System.getProperty("user.home")+"/insights/";
List<String> commands = new ArrayList<>();
commands.add("python3");
commands.add(dir+"sentiment_corr_conn.py");
//commands.add(""+_categoryId);
String ret="";
try {
ProcessBuilder pb = new ProcessBuilder().command(commands);
final Process p = pb.start();
BufferedReader output = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader error = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String line="";
while ((line = output.readLine()) != null) {
ret+=line+"<br/>";
}
while ((line = error.readLine()) != null) {
ret+="ERROR: "+line+"<br/>";
}
} catch (IOException e) {
return("EXCEPTION: "+e.getMessage()+"<br/>");
}
return(ret);
}
stdoutat all?new InputStreamReader(p.getInputStream())? Don't you wantp.getOutputStream()here?getInputStreamreturns anInputStream. It's NOT because it is connected tostdinof the child process, as one might think.