PyBox / Blog / How to

Install pip Packages on Android: NumPy and pandas

pip works on Android, with one catch. Pure Python packages install straight from PyPI. Packages with compiled code need an Android build.

Install pip Packages on Android: NumPy and pandas: the PyBox screen this guide uses
PyBox is the Python IDE I build. The steps below use it, and the ideas carry over to any Android coding app. Get it on Google Play.

Two kinds of package

  • Pure Python: requests, rich, flask. These are just .py files and install from PyPI.
  • Compiled: numpy, scipy, opencv-python. They contain C or C++ code and must be built for Android's CPU, arm64 or x86_64.

Install with requirements.txt

  1. Open your project and create requirements.txt.
  2. List one package per line.
  3. Tap sync.
requests
rich
numpy
pandas
matplotlib

Install in the terminal

pip install requests
pip list
pip show numpy

Common errors

ErrorCauseFix
No matching distributionNo wheel for AndroidUse a package PyBox ships a wheel for, or a pure Python alternative
Failed building wheelNeeds a native compilerAvoid building from source on the phone
ModuleNotFoundErrorInstalled in a different interpreterInstall from the same project environment
Network errorNo connectionConnect once to download, then work offline

What ships ready

PyBox provides prebuilt wheels for NumPy, SciPy, pandas, Matplotlib, scikit-learn, PyTorch, TensorFlow Lite, ONNX Runtime and OpenCV. See Python libraries on Android for the list.

Questions

How do I install pip packages on Android?

In PyBox, add the package to requirements.txt and sync, or run pip in the terminal. Pure Python packages come from PyPI. Compiled libraries come as prebuilt Android wheels.

Why does pip fail to build NumPy on a phone?

Building native code needs a compiler toolchain a phone lacks. Use a prebuilt wheel built for Android.

Can I install packages offline?

You need a connection to download them once. After that they work offline.

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

Code Python on your phone.