Update: The content of this article is no longer applicable for this tablet model. Termux and Jupyter Notebook still work, however Termux does no longer support (for a long time) Android 6.0 and older. The result is that crucial libraries like Matplotlib fail to install. It is still usable but only for basic tasks.
All started with this article from Leonardo Uieda’s blog (thanks Leonardo). I had already tried to run Python on Android, using the Pyonic Python 3 interpreter. Not bad, but… hey, it started to be hard to do anything else than the standard Python libraries. I needed something more. I needed all the standard libraries, numpy, matplotlib, seaborn, pandas… the works in a few words, to make my little HUAWEI M2 810W be helpful to start jotting down some algorithm while on the move, and reuse exactly the same code somewhere else.
Why not a laptop would you say. Of course you may be right. A keyboard is what you need most of the time. But sometimes the laptop is just not handy, or it is overkill.
That’s where the Termux project came to the rescue, and based on this, Leonardo Uieda could install Python 3.6 and pip, and from there a bunch of applications, including Python 3.6 and all its major libraries, including numpy, matplotlib, and pandas (not yet sqlite3 though). Note: Termux can be installed and run for free with no limitations, but some of its most interesting add-ons can be obtained at a price.
The installation is rather easy, all is very well explained by Leonardo, I had only one issue and this materialized while installing numpy. I do not know if this is still the case, but I solved it by installing a specific version of numpy following the instructions found in this article and basically the line that saved my day was the following:
1 |
LDFLAGS=" -lm -lcompiler_rt" pip install numpy==1.12 |
Other people has had similar issues with other libraries, for me this was the only one. After that I have been able to do what I wanted with it and here there are some screenshots!
This is the initial Termux screen, it looks just like a standard linux terminal. The command to install applications is “apt install”. For instance:
1 |
apt install python |
In the bottom the url of the Jupyter Notebook home can be seen. That needs to be copied and pasted in the Chrome browser address bar:
From there, a new notebook can be created, or an existing one can be opened, just as on your PC. Here I have two more examples with matplotlib, a multiplot with histograms and a radar plot.
Here the application is just a set of visualization of the Italian “Superenalotto” lottery extractions. The multiplot represents the frequency of extraction per number position, each number has been given 18 buckets of 5 values each.
On the radar plot, the black area (should be points connected really) represents the averages, while the red areas is the set of all the draws, plotted with a very low opacity value to visualize somehow the frequencies of the drawn numbers.
That’s it! Perfectly usable and makes your flights much more enjoyable! 😉