I am trying to run a python script hello.py from an Android process.
Here are the steps I followed:
- I have purchased python binaries and need related libraries.
- I tested them and they work in a terminal emulator.
- I added them to my resource folder and copied them to private storage and made them executable.
But still I get the following error:
07-19 13:35:15.391 26991-26991/com.vibhinna.example I/System.out: Here is the standard output of the command: 07-19 13:35:32.001 26991-26991/com.vibhinna.example I/System.out: Here is the standard error of the command (if any): 07-19 13:35:32.001 26991-26991/com.vibhinna.example I/System.out: Fatal Python error: Py_Initialize: Unable to get the locale encoding 07-19 13:35:32.001 26991-26991/com.vibhinna.example I/System.out: ImportError: No module named 'encodings' 07-19 13:35:32.001 26991-26991/com.vibhinna.example I/System.out: Current thread 0xb6f0dec8 (most recent call first):
Here is the code used to execute the file.
String pyPath = getFilesDir().getAbsolutePath() + "/usr/bin/python"; String helloPath = getFilesDir().getAbsolutePath() + "/usr/bin/hello.py"; ProcessBuilder pb = new ProcessBuilder(pyPath, helloPath); Process proc = pb.start(); BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
What am I doing wrong? How can I make this work?
source share