1

I want to use ProcessBuilder to execute a python script. I can execute this script with the command "python3 myscript.py" without any problem. But When I use ProcessBuilder in java, I get an error from my script :

import numpyImportError: No module named 'numpy'

numpy is the module that I want to use, but I can't find it. This is the way I call my script :

ProcessBuilder builder = new ProcessBuilder("python3","main.py","-rd ",selectedFile.getAbsolutePath());
builder.redirectErrorStream(true);
Process process = builder.start();

1 Answer 1

3

You need to specify your python path:

run in your terminal: "which python3"

ProcessBuilder builder = new ProcessBuilder("your/python/path/python3","main.py","-rd ",selectedFile.getAbsolutePath());
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.