I am a programming enthusiast. One or another program always keep running on my PC anytime any day. Last time I was working with a web scrapper. Everything was good but some parameters were out of control.
- Electricity cut, being in India this is the most common hurdle. Laptop battery can last up to 2.5 hr but WiFi doesn’t work without electricity.
- While I remain at the office and your personal work is in progress at home, it is very difficult to keep eye on. Sometimes I realize that just after I left for office the program encountered an error or other failure and my entire day gone wasted.
To make peace with all these issues, I found a new way with “QPython”. “QPython is a script engine which runs Python programs on Android devices. It also can help developers develop Android applications.”
In short Q Python is a Python compiler that can run your Python scripts on any Android device. This informative blog would be very short and we will move forward step by step till you get an exact idea on how to run your python scripts on the android device even while you are enjoying road trip or paragliding.
Installing Q Python is as easy as you install any other application from play store. Go to plays store, search for Q Python and here it is.
Figure 1. QPython in Android play Store.
Working with QPython
Console, where you can code as you do in normal python console. I found this functionality of little use as it is very inconvenient to type longer code on phone’s keyboard. The console can be used effectively to test small-small snippet of code.
Figure 2. QPython native console
Editor window is the second functionality. This is almost full flagged python editor. It supports auto indentation, code highlight, open, save, edit, run, text wrapping, search and goto line like basic functions. Editor functionality is not limited to just simple scripts but it does allow to manage the entire project where code may span to multiple files. You can manage entire projects as we do with Pycharm or Spyder or any other IDE.
Figure 3. QPython native Editor
Libraries, allow us to manage packages. Installing packages is supported with both pip [python official package installer] and custom QPython package manager.
Figure 4. QPython native Libraries manager.
What I saw particularly while installing packages to QPython is
Small or large packages which are written in Python get installed without any hurdle. Example requests, beautifulsoup, wikipedia, bottle etc.
Package with dependencies like extra model files and have core functional written in Cython or C sometimes fails to get installed. Example Numpy, Tensorflow etc
Usages / Productivity
QPytohn can be very useful for writing small snippets for the following purpose.
Web scrappers which takes a long time and due to uneven data often require to monitor
‘bottle’ package you can make your phone a web server.
Many native Android functions can be controlled through QPython such as:
Alarm me when battery charged to 95% or drained to 5%.
Alarm me/toast a notification when web crawler program is halted due to error.
Alarm me/toast a notification when I am out of Network and crawler is paused for a while. Crawler again continues when the network is detected.
Practically I have used QPython to crawl millions of pages from Wikipedia and duck duck go. I am exploring more possibilities, will continue to extend this blog as an when I will explore more things.