Run Python for Android (Qpython) in Android Terminal
Solution 1
Try this command in your terminal:
$sh data/data/com.hipipal.qpyplus/files/bin/qpython.sh
Terminal will prompt a Python console.
Solution 2
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
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.
Solution 3
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!
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:
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!
fteinz
Updated on June 05, 2022Comments
-
fteinz almost 2 years
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/
My Script to import the environment variables qpython needs looks like:
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:
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 Stackoverflow the same Question but the posted solution ist a link how is down.
Other Tutorial on throws only errors http://dinostest.com/node/28
-
fteinz almost 9 yearsIt's clear. I have tryed both. python and $python. I habe copy and paste the Text form the tut.
-
pooralfie almost 9 yearsthe guide on the qpython wiki is for running python in other terminal apps installed on the android device, not ADB shell
-
Pitto over 8 yearsIf I try simple things like $python print 2 it works if I launch a script it says I have no execute permission (and chmod +x is not working on droid term)
-
skriems over 8 yearsHey fteinz! Personally I would roll back and perform the above steps. Should be saver and the linker will most likely be overwritten the next time you update your phone...
-
m3nda about 7 years@Pitto Try with octal,
chmod 0777 file
. Case you wan't to chmod +x means 7, so, 0755 will be ok for your user, or even root. The chmod implementation of Android don't understand short flags like +x.