Python for Android (Py4A 2.6) is wonderful!!! But QPython (2.7) is a lot more powerful and continuously developed. Now I try to integrate Qpython's Python into Android (5.1 CM12) Terminal / ADB described in this Tutorial:http://wiki.qpython.org/en/diveinto/
Android的Python (Py4A 2.6)太棒了!!!但是QPython(2.7)更强大,并且不断发展。现在,我尝试将Qpython的Python集成到Android (5.1 CM12)终端/ ADB中,在本教程中描述:http://wiki.qpython.org/en/diveinto/。
My Script to import the environment variables qpython needs looks like:
我的脚本导入环境变量qpython需要如下:
TERM=screen
PATH=/data/data/com.hipipal.qpyplus/files/bin:/system/bin:/system/xbin
LD_LIBRARY_PATH=.:/data/data/com.hipipal.qpyplus/files/lib/:/data/data/com.hipipal.qpyplus/files/:/data/data/com.hipipal.qpyplus/lib/
PYTHONHOME=/data/data/com.hipipal.qpyplus/files
ANDROID_PRIVATE=/data/data/com.hipipal.qpyplus/files
PYTHONPATH=/storage/emulated/0/com.hipipal.qpyplus/lib/python2.7/site-packages/:/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/:/data/data/com.hipipal.qpyplus/files/lib/python2.7/:/data/data/com.hipipal.qpyplus/files/lib/python27.zip:/data/data/com.hipipal.qpyplus/files/lib/python2.7/lib-dynload/:/storage/emulated/0/com.hipipal.qpyplus/scripts
PYTHONSTARTUP=/storage/emulated/0/com.hipipal.qpyplus/lib/python2.7/site-packages/qpythoninit.py
PYTHONOPTIMIZE=2
TMPDIR=/storage/emulated/0/com.hipipal.qpyplus/cache
AP_HOST=127.0.0.1
AP_PORT=58418
AP_HANDSHAKE=01805a68-c04c-4e21-bd54-ac8732f3a8da
ANDROID_PUBLIC=/storage/emulated/0/com.hipipal.qpyplus
ANDROID_PRIVATE=/data/data/com.hipipal.qpyplus/files
ANDROID_ARGUMENT=/storage/emulated/0/com.hipipal.qpyplus/scripts
Shell session:
Shell会话:
u0_a101@C1905:/ $ source /sdcard/qpyenvnew.sh
u0_a101@C1905:/ $ $python
u0_a101@C1905:/ $ hmm do nothing?!
I get no output.
我没有输出。
I have found here on * the same Question but the posted solution ist a link how is down.
我在*上找到了同样的问题,但是张贴出来的解决方案是一个链接。
Other Tutorial on throws only errors http://dinostest.com/node/28
其他教程只提供错误http://dinostest.com/node/28。
4 个解决方案
#1
3
Try this command in your terminal:
在你的终端试试这个命令:
$sh data/data/com.hipipal.qpyplus/files/bin/qpython.sh
Terminal will prompt a Python console.
终端将提示Python控制台。
#2
1
If your script for the environment variables was obtained by running the code from the tutorial link, it should be correct.
如果您的环境变量脚本是通过运行教程链接中的代码获得的,那么它应该是正确的。
If what you have pasted is exactly what you entered, the problem would be that you tried to run pyhton by typing $python
when it should have just been python
如果您所粘贴的是您输入的内容,那么问题将是您试图通过输入$python来运行pyhton,而它应该只是python。
Pre-fixing with $ is used to reference the value of a variable, so entering $python
referenced the value of the variable python but does nothing with it, hence no feedback.
前缀$用于引用变量的值,因此输入$python会引用变量python的值,但是没有使用它,因此没有反馈。
#3
1
EDIT2: Although it's not a direct answer to this question I suggest having a look at the App 'Termux'. You can install Python2/3 via apt, virtualenv/-wrapper etc... Much more powerfull!
EDIT2:虽然这不是直接回答这个问题,但我建议你看一下这个应用程序“Termux”。您可以通过apt、virtualenv/-包装器等方式安装Python2/3。更强大的!
EDIT: Since /data/data... is only accessible as root, the following must be done as root!
Take care that the python executables path is in your $PATH. That wasn't the case even after having run the script from the tutorial (your script). If it's not present simply type:
编辑:既然/数据/数据……只有作为根才能访问,以下必须作为根来完成!注意,python可执行路径位于您的$ path中。即使在运行了教程(您的脚本)的脚本之后,情况也不是这样。如果它不是简单的类型:
export PATH=/data/data/com.hipipal.qpyplus/files/bin:$PATHor follow theses steps. In short: create a file in /sdcard (here ".bashrc") with the above line. After that type:
source .bashrc(init.sh is located in /data/data/com.hipipal.qpyplus/files/bin as well)
source init.sh
Then fire up Python with
python-android5which is the PIE compatible executable for Phone with Lollipop and above. But be aware: For whatever reason I couldn't exit() or quit() the Python prompt but I was able to run Script from the Terminal!
Have fun!
玩得开心!
#4
0
EDIT: I spotted this: PythonForAndroid. It is a fork of PythonForAndroid that is still alive, and this versions are able to run on Android L (Python3 on 5.1.1 in my case). Also check the SL4A linked there, it works great on Lollipop.
编辑:我发现了这个:PythonForAndroid。它是一个仍然存在的python的分支,并且这个版本可以运行在Android L上(在我的例子中是5.1.1的Python3)。也检查一下SL4A链接,它在棒棒糖上效果很好。
Thanks to the answers above I made a super easy solution. If you have root: Create a file "python" and type the following line in it:
由于上面的答案,我做了一个非常简单的解决方案。如果您有根:创建一个文件“python”并在其中键入以下一行:
sh data/data/com.hipipal.qpyplus/files/bin/qpython-android5.sh
Place this file in your /system/bin directory and you can access python from everywhere using the command 'python'.
将该文件放入/system/bin目录中,您可以使用“python”命令从任何地方访问python。
#1
3
Try this command in your terminal:
在你的终端试试这个命令:
$sh data/data/com.hipipal.qpyplus/files/bin/qpython.sh
Terminal will prompt a Python console.
终端将提示Python控制台。
#2
1
If your script for the environment variables was obtained by running the code from the tutorial link, it should be correct.
如果您的环境变量脚本是通过运行教程链接中的代码获得的,那么它应该是正确的。
If what you have pasted is exactly what you entered, the problem would be that you tried to run pyhton by typing $python
when it should have just been python
如果您所粘贴的是您输入的内容,那么问题将是您试图通过输入$python来运行pyhton,而它应该只是python。
Pre-fixing with $ is used to reference the value of a variable, so entering $python
referenced the value of the variable python but does nothing with it, hence no feedback.
前缀$用于引用变量的值,因此输入$python会引用变量python的值,但是没有使用它,因此没有反馈。
#3
1
EDIT2: Although it's not a direct answer to this question I suggest having a look at the App 'Termux'. You can install Python2/3 via apt, virtualenv/-wrapper etc... Much more powerfull!
EDIT2:虽然这不是直接回答这个问题,但我建议你看一下这个应用程序“Termux”。您可以通过apt、virtualenv/-包装器等方式安装Python2/3。更强大的!
EDIT: Since /data/data... is only accessible as root, the following must be done as root!
Take care that the python executables path is in your $PATH. That wasn't the case even after having run the script from the tutorial (your script). If it's not present simply type:
编辑:既然/数据/数据……只有作为根才能访问,以下必须作为根来完成!注意,python可执行路径位于您的$ path中。即使在运行了教程(您的脚本)的脚本之后,情况也不是这样。如果它不是简单的类型:
export PATH=/data/data/com.hipipal.qpyplus/files/bin:$PATHor follow theses steps. In short: create a file in /sdcard (here ".bashrc") with the above line. After that type:
source .bashrc(init.sh is located in /data/data/com.hipipal.qpyplus/files/bin as well)
source init.sh
Then fire up Python with
python-android5which is the PIE compatible executable for Phone with Lollipop and above. But be aware: For whatever reason I couldn't exit() or quit() the Python prompt but I was able to run Script from the Terminal!
Have fun!
玩得开心!
#4
0
EDIT: I spotted this: PythonForAndroid. It is a fork of PythonForAndroid that is still alive, and this versions are able to run on Android L (Python3 on 5.1.1 in my case). Also check the SL4A linked there, it works great on Lollipop.
编辑:我发现了这个:PythonForAndroid。它是一个仍然存在的python的分支,并且这个版本可以运行在Android L上(在我的例子中是5.1.1的Python3)。也检查一下SL4A链接,它在棒棒糖上效果很好。
Thanks to the answers above I made a super easy solution. If you have root: Create a file "python" and type the following line in it:
由于上面的答案,我做了一个非常简单的解决方案。如果您有根:创建一个文件“python”并在其中键入以下一行:
sh data/data/com.hipipal.qpyplus/files/bin/qpython-android5.sh
Place this file in your /system/bin directory and you can access python from everywhere using the command 'python'.
将该文件放入/system/bin目录中,您可以使用“python”命令从任何地方访问python。