Using python and matplotlib on android

限于喜欢 提交于 2019-11-27 11:20:46

问题


Is there a way to set up python 2.7.x + matplotlib on an android tablet so that you can run simple standard python code? I would like to be able to run the same scripts I run on my Linux desktop. This is just for my own use and I don't need to distribute the code to anyone else.

As a concrete example, is it possible to run this script?

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0, 5, 0.1);
y = np.sin(x)
plt.plot(x, y)

回答1:


Is it easy, no.

Can it be done? Yes. I believe a skilled Python / Android developer could do it in 2 to 8 hours of effort.. It's a rare and complex request.

Why do I think it can be done? This sample: http://matplotlib.org/examples/pylab_examples/webapp_demo.html

Using a different library, and not abstracted for data without live hardware, this sample shows me that SL4A can do web-based graphics: http://www.smartphonedaq.com/android-python-ecg.page

Now, if you were talking native GUI graphics in Android - then I'm focused way too much on the web methods of publishing with SL4A ;)




回答2:


Pydroid is great for Matplotlib on Android, supports Numpy and many other libraries:

Pydroid for Python 2.7

Pydroid 3 for Python 3.6




回答3:


There is an app called Gnuroot that allows you to run a kind-of chroot (proot), where you can install a linux distro such as debian, archlinux...
For the gui, there is the option to run a vncserver for an X server and use some android vnc client app to show the screen.

I use the non-gui version of gnuroot and it works well. I now have a command line debian wheezy on android lollipop arm. One minor thing i miss, is armhf (hardware floating point which my nexus7's processor can do) support instead of armel (software floating point).




回答4:


Yes, it can be done, even without root. You need the termux app, it basically is a terminal emulator with a full Linux environment and via apt install python, for example, you can install python.

The main webpage is here, and it is of course available via the standard market. (The termux wiki is a helpful place.)




回答5:


ever heard of qpython? http://qpython.com/ i personally never used it, but my colleague were quite handy with it so you may want to look at that




回答6:


I've read somewhere that scipy and matplotlib cannot be compiled for android, someone did it for numpy though

https://code.google.com/p/android-scripting/issues/detail?id=260




回答7:


You could set up a cheap server (Raspberry Pi?) and create an ssh connection to it to access full python functionality through a vnc viewer android app or the shell




回答8:


You can try MathSys. It's a wrapper around Python, and it has matplotlib inside.

Unfortunately, MathSys is rather convoluted, and it's an alpha version. Apparently, nobody is working on a beta version. You'll want to write any complicated code in an external file. import works fine in MathSys.




回答9:


Upon searching numpy android on Google, I found a very nice library. I guess it might be helpful.




回答10:


Here is the code, this works after installing GNURoot Debian as you said. Just a detail : my graph is exported directly in a .png file :

from pylab import *
import matplotlib.pyplot as plt
plt.switch_backend('agg')
x = linspace(-5, 5, 100)
y = sin(x)
plot(x, y)
out_png = 'out_file.png'
plt.savefig(out_png, dpi=150)



回答11:


Use the linux shell, I have it git python and pip installed on my phone. I used gnuroot in the play store.. You can apt-get install python pip from there



来源:https://stackoverflow.com/questions/18353203/using-python-and-matplotlib-on-android

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