Just tested andYou misunderstand a few things here.
return Runtime.getRuntime().exec(pathname).toString(); Look at the following piece of code exec(pathname) You pass the pathname argument to the exec method. However to execute a python file you should pass the pathname of the python script to the python executable. So the command would look like this works:
python path/to/file Note: If the path to the file contains spaces, make sure to wrap it in "double qoutes"
The second thing that you misunderstand is the following: exec(...).toString(). The exec method returns a Process, so calling the toString(), won't give you the output of the python script.
In order to get that output, we need to read the input stream of the executed process. You can get this input stream by calling Process#getInputStream()
Example