0

I am calling Python(Anaconda) code from Java using ProcessBuilder. It was working fine when I had installed only Python. But now I have removed Python and installed Anaconda. The code to call Python is not working now. Getting the following error.

 com.api.ai.helper.MLPythonAPI callPyhonScriptToPredict
SEVERE: null
java.io.IOException: Cannot run program "python": CreateProcess error=2, The system cannot find the file specified
       at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
       at com.api.ai.helper.MLPythonAPI.callPyhonScriptToPredict(MLPythonAPI.java:66)

I am using python 3.6.1(anaconda3 4.4.0 64 bit) and following code to execute Python

ProcessBuilder pb = new ProcessBuilder().inheritIO().
                    command("python", "C:\\my_code\\test.py", userSays, filePath);
            Process p = pb.start();
            p.waitFor();

Can somebody help me in this.

user2550098
  • 163
  • 1
  • 13

1 Answers1

0

I passed the complete Python path in command method(in stead of "python" and now it is working fine.

user2550098
  • 163
  • 1
  • 13