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.

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.