PyBox / Blog / How to

Jupyter Notebook on Android: a setup guide

You can run JupyterLab locally on an Android phone or tablet, offline after setup. Here is the whole path.

Jupyter Notebook on Android: a setup guide: the PyBox screen this guide uses
PyBox is the Python IDE I build. Everything below works with it, and the steps are the same ideas you would use anywhere. Get it on Google Play.

First run

Tap New Notebook on the PyBox home screen, pick a template or a blank notebook, and name it. The first time, PyBox downloads JupyterLab, Matplotlib, ipywidgets, ipympl and a touch plugin, and shows progress. This needs a connection once.

Opening the notebook

PyBox starts JupyterLab on localhost:8888 and opens it in your browser. You get the normal JupyterLab interface: file browser, tabs, cells and a kernel called Python 3 (ipykernel).

Interactive plots

%matplotlib widget
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 2 * np.pi, 400)
plt.plot(x, np.sin(x))
plt.plot(x, np.sin(2 * x))
plt.show()

With ipympl the figure is interactive: pan and zoom with touch.

Adding packages

Use a cell with %pip install statsmodels. The lab notebooks already include such a cell at the top when they need one.

Try a real analysis

The Time Series Analysis notebook takes the Keeling CO2 curve through decomposition, stationarity tests, ACF and PACF and a seasonal ARIMA model. The Regression and Statistical Inference notebook works through 442 patient records.

Tips

  • Restart the kernel and run all before you share a notebook.
  • Close tabs you are not using. Phones have limited memory.
  • Copy notebooks to a computer by browsing the PyBox folder over USB.

The full list of notebooks is on the JupyterLab on Android page.

Questions

Does Jupyter work offline on Android?

After the first setup it does. The server runs on the device.

Where are my notebooks stored?

As .ipynb files in the PyBox folder in shared storage, so you can copy them to a computer.

Anshuman MishraBuilds PyBox at Vytros, a Python IDE for Android. About the developer.

Code Python on your phone.