Skip to content

Latest commit

 

History

History
65 lines (48 loc) · 2.78 KB

android.rst

File metadata and controls

65 lines (48 loc) · 2.78 KB

Using Python on Android

Python on Android is unlike Python on desktop platforms. On a desktop platform, Python is generally installed as a system resource that can be used by any user of that computer. Users then interact with Python by running a :program:`python` executable and entering commands at an interactive prompt, or by running a Python script.

On Android, there is no concept of installing as a system resource. The only unit of software distribution is an "app". There is also no console where you could run a :program:`python` executable, or interact with a Python REPL.

As a result, the only way you can use Python on Android is in embedded mode – that is, by writing a native Android application, embedding a Python interpreter using libpython, and invoking Python code using the :ref:`Python embedding API <embedding>`. The full Python interpreter, the standard library, and all your Python code is then packaged into your app for its own private use.

The Python standard library has some notable omissions and restrictions on Android. See the :ref:`API availability guide <mobile-availability>` for details.

Adding Python to an Android app

These instructions are only needed if you're planning to compile Python for Android yourself. Most users should not need to do this. Instead, use one of the following tools, which will provide a much easier experience:

If you're sure you want to do all of this manually, read on. You can use the :source:`testbed app <Android/testbed>` as a guide; each step below contains a link to the relevant file.