I am calling a Python script from Java by mentioning the Python script name in the ProcessBuilder method within Java code. Code snippet for the same is given below :
String[] commandToProcessDocument = { "python", "C:\\Users\\User_Name\\sample_integration.py"};
ProcessBuilder pb = new ProcessBuilder(commandToProcessDocument);
Process process = pb.start();
And the Python script has the following lines in it :
import pandas as pd
if __name__ == '__main__':
print("Welcome To Python")
a = 5
b = 10
c = a+b
print(c)
df = pd.read_csv("Test_Dataset.csv")
print("came after reading")
When I execute this python script either in Spyder IDE or in Command Prompt, I am able to see the 3rd print statement which is "came after reading". Attached is the screenshot that shows the Command Line output
But when I try to execute the same python script from Java using Netbeans IDE, the execution doesn't go beyond the pd.read_csv line. It just prints "15" which is the value of sum of 'a' and 'b' variables and keeps on getting executed without ending.
Is there anything I need to do specially for invoking Pandas from java or am i missing anything very basic here ?