emteria Blog | Android OS experts

Native Python support for Android devices

Written by Igor Kalkov-Streitz | Nov 5, 2026

Customers have asked us so many times whether they can run their own Python scripts on their Android devices. Until now, the answer meant heavy workarounds. Our Android builds now include Python 3.14 natively: python3 runs directly on the device, like any built-in tool, so you can add your scripts without extra packaging. It adds 21.8 MB to the system image and starts in 180ms on a Raspberry Pi 5.

Running Python on Android used to need workarounds

Python itself has supported Android officially since version 3.13 (PEP 738), and since Python 3.14, python.org publishes ready-made Android builds. But the Python documentation for Android assumes that Python lives inside an app: on Android, it says, there is "no concept of installing as a system resource". Each app that wants Python bundles its own copy, and that copy only runs inside the app.

For a script that should simply run on a device (for example as a provisioning step, a diagnostic check or a vendor tool), we had two options in the past: Wrap the script in a custom app, or set up a container or an emulated Linux environment on top of Android and install Python there. Both add a lot of work. The extra layer costs performance on every run, and it is one more software stack on the device that needs its own security updates.

We added native Python support to the Android OS

We build the operating system, so we can add Python the way Android adds its own components. The hard part, a complete and correct Python for Android, is already done upstream. The remaining question was how to install it on the system.

Python is more than one program file. Modules such as ssl, socket and sqlite3 are separate library files that Python loads when a script needs them, 67 of them in our build. Android only lets ordinary programs load libraries from a few fixed directories, so a Python simply copied onto the system would fail as soon as a script imports one of these modules.

We therefore ship Python as an APEX, Android's format for self-contained system modules. An APEX brings its own rules for loading libraries, so Python finds all of its modules, including its own copies of OpenSSL and SQLite, without affecting the rest of the system. The standard library, 582 files and 12 MB, is packed into a single 2.9 MB file. A small launcher makes python3 available in every shell, like any other command:

rpi5:/ $ python3 -VV
Python 3.14.7 (tags/v3.14.7:823f032, Aug  5 2026, 10:34:26) [Clang 18.0.4]

rpi5:/ $ python3 -c "import ssl, sqlite3, ctypes, platform, subprocess
print(ssl.OPENSSL_VERSION)
print(platform.android_ver())
print(subprocess.run(['getprop','ro.product.model'],
capture_output=True, text=True).stdout.strip())"
OpenSSL 3.5.7 9 Jun 2026
AndroidVer(release='17', api_level=37, manufacturer='brcm',
model='Raspberry Pi 5', device='rpi5', is_emulator=False)
Raspberry Pi 5

rpi5:/ $ time python3 -c "pass"
    0m00.18s real     0m00.14s user     0m00.03s system

The script imports encryption, database and system modules, calls an Android system command and prints its output, all as an ordinary process on the device. Because Python is part of the system, it is available everywhere on the device: to a technician over adb, to background services and to OTA updates.

Start adding your own Python scripts

Work that used to need an embedded Android developer now needs a Python script:

  • Vendor tools run as they are. Hardware vendors often ship flashers, configuration editors and image validators in Python. They run on the device instead of being rewritten.
  • Provisioning and end-of-line checks. Reading serial numbers, writing per-unit configuration and checking that a board left the factory in the right state: a script written for the production PC runs unchanged on the device.
  • Field diagnostics without a new build. Copy a script to the device and run it. With encryption, a database, HTTP and JSON in the standard library, it can read local data, call an API and send a report, without an app to write, sign and install.
  • Maintenance as part of an update. System services and OTA update steps can call Python, so data migrations and one-off fixes ship with the update.
  • One test suite for PC and device. Test code written for your CI runs on the device as well, instead of being maintained twice.

We use an existing Raspberry Pi Python tool unchanged

To try this with a real tool, we picked Raspberry Pi's rpi-eeprom. On a Raspberry Pi 5, it reads and changes the bootloader configuration stored on the board, for example the boot order. The part that does the work is a Python script of 639 lines. On our build, it runs unchanged:

rpi5:/ $ rpi-eeprom config
[all]
BOOT_UART=1
BOOT_ORDER=0xf461
NET_INSTALL_AT_POWER_ON=0
NET_INSTALL_ENABLED=0
DISABLE_HDMI=1

The shell scripts around it needed several changes, because Android's command-line tools and file system layout differ from a Linux desktop. But the Python script itself needed none, because it only uses Python's standard library. Tasks like this used to mean porting a tool to Android. Now they mostly mean copying it to the device.

Available on Raspberry Pi, ready for other hardware

Python is part of our Android images for all Raspberry Pi models, from Android 14 to Android 17, including all Live releases. Python is built as an optional module, so we can add it to the Android OS for other hardware as well.

Our build includes Python's standard library, without pip. Your own Python code runs as it is; packages with compiled C extensions need to be built for Android first. A few desktop-oriented modules, such as multiprocessing and curses, are not available yet. Scripts run with the permissions of whoever starts them, like any other program, so Android's security model stays fully in place.

If your devices depend on Python scripts or tools, talk to us about adding Python to the Android OS for your hardware.

Raspberry Pi is a trademark of Raspberry Pi Ltd.