How to run QPython over adb shell

房东的猫 提交于 2019-12-23 03:12:39

问题


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?


回答1:


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
>>>



回答2:


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/



来源:https://stackoverflow.com/questions/27549472/how-to-run-qpython-over-adb-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!