python logo


Python hosting: Host, run, and code Python in the cloud!

Python scripts can be run on Android using the Scripting Layer For Android (SL4A) in combination with a Python interpreter for Android.

Related courses:
You may like:
Building Android Apps in Python Using Kivy

The SL4A project makes scripting on Android possible, it supports many programming languages including Python, Perl, Lua, BeanShell, JavaScript, JRuby and shell. The SL4A project has a lot of contributors from Google but it is not an official Google project.

Scripts can access Android specific features such as calling, text message (SMS), take picture, text to speech, bluetooth and many more.

In this article you will learn how to run Python on Android devices using SL4A.

SL4A is designed for developers

Keep in mind that SL4A is designed for developers and in alpha quality software.

Install SL4A


First enable installation of programs from unknown sources. By default Android devices can only install apps from the Google Play Store.

You have to enable the permission ‘Install from Unknown Sources’, by going to Settings -> Security -> Unknown Sources and tap the box.

After you have have updated these settings donwload the SL4A APK. Visit on your Android device and download the SL4A APK (or use the QR code on the right).
Once downloaded an installation menu will popup, requesting all permissions on your Android device.

SL4A-Permissions SL4A-Permissions

Install Python 3 for Android

qr-python-3-for-android QR Code Python 3 for Android

Install the Py4A app. The Python for Android app is built to run solely on

Android devices. You should use this app together with SL4A.

You can pick any version of Py4A, but bare in mind the supported version on Android:

  • Python 2 requires Android Device >= 1.6

  • Python 3 requires Android Device >= 2.3.1

The git repository is:

You could also use the QR code on the right using a QR scanner on your Android device.

Once Py4A is installed, start the app and press install. This will install the Python interpreter.

Android-Python-3-Install Android Python 3 Install



Open SL4A again. Many scripts will appear (in a list). You can now run Python scripts on your Android Device!

Python-On-Android Python-On-Android


Press on a program such as A little popup will be shown. Pressing on the terminal icon will start the Python script.

SL4A-Python-Menu SL4A-Python-Menu

The third button (the pencil) will open an editor. This is not a full blown IDE but a simple editor.
It doesn’t have syntax highlighting.

Scripting on Android

You may prefer your favorite Python editor whatever it may be (vim/emacs fans here? PyCharm? Atom?)
All scripts are stored in /sl4a/scripts/

Note: File extension

If you installed the Python 3 interpreter, the programs will show with a .py3 extension instead of a .py extension.

A simple program (Spaceship Launch):

"""TTS Rocket Launch."""

__author__ = 'Frank <[email protected]>'

import android

droid = android.Android()
message = "Python on Android"

for i in range(10,0,-1):

droid.ttsSpeak("We have lift off!")

More examples:


Leave a Reply:

BADARINARAYANA ACHARYA N S 2021-05-04T15:41:10.547Z

I tried to install and run SL4A on redmi note 7 pro where android 10 is installed. It is showing pop-up message 'this app built for an older version of Android, this may not work properly' and add etc options of SL4A is showing.

Please give me a solution to run SL4A on android 10

Frank 2021-05-04T15:41:10.547Z

Try contacting the sl4a creators, it seems its no longer supported on Android 10 and newer. You could also try an alternative (see app store)