I installed the QPython on my (rooted) phone. I'm having trouble, however, running the python binary over the adb shell (busybox).
I can run the python binary after setting:
export LD_LIBRARY_PATH=/vendor/lib:/system/lib:/data/data/com.hipipal.qpyplus/files
However, I cannot import any module from the standard library even setting $PYTHONPATH
export PYTHONPATH=/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages
I found a piece of advice how to run QPython in different terminal on the community wiki ( http://wiki.qpython.org/hacker/#how-to-execute-qpythons-python-in-other-terminals ), and I dumped the enviromnent and loaded it in the adb shell, the loaded python still could not load any libraries from standard library, like random.
Loading standard libraries from QPython console works just fine. Any pointers?
I got python to work by following the provided link, http://wiki.qpython.org/hacker/#how-to-execute-qpythons-python-in-other-terminals, prepending all lines in the script with export
, then running as root ". /sdcard/qpyenv.sh
". Finally I could run "python
" and "import os
" and all warning at the top disappeared.
root@trelte:/ # . /sdcard/qpyenv.sh
root@trelte:/ # python
Python 2.7.2 (default, Oct 25 2014, 20:52:15)
[GCC 4.9 20140827 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>>
In my experience you only need to set two variables for this to work:
export PYTHONHOME=/data/data/org.qpython.qpy/files
export LD_LIBRARY_PATH=.:/data/data/org.qpython.qpy/files/lib/:/data/data/org.qpython.qpy/files/:/data/data/org.qpython.qpy/lib/
but you need to run as root so you can access things in /data/data/org.qpython.qpy/