Stack OverflowIs there a way to run Python on Android?
[+1795] [25] e-satis
[2008-09-19 13:21:12]
[ android python jython ase android-scripting ]
[ ]

We are working on an S60 [1] version and this platform has a nice Python API.

However, there is nothing official about Python on Android, but since Jython [2] exists, is there a way to let the snake and the robot work together?

(6) Let's test Joel's theory about the possibility of updates for well-google-ranked SO posts. See below or this:… - unmounted
(31) I mean the contrary. Given the little content of this post, if it's well ranked, it must be a huge expectation. I strongly hope the best for this project, I'm myself more a pythonista than a Java guy and coding Android with this language would sky rock the prototyping phase. - e-satis
I was kidding too. I meant that you should update the question, since some answers have been obsoleted by google's announcement. - unmounted
(2) Oh, right... I don't think updating the question is usefull, but changing the accepted answser certainly is. - e-satis
(2) A scripting language inside a bytecode application inside a virtual machine it spell slowness. no wonder why those phones need dualcore even quadcore soon. Im not hating on Android or Python it just that... - user457015
(1) Technically, when you code in Python, you always code using "a scripting language", it always generate bytecode, and it always run in a virtual machine. - e-satis
(3) @e-satis you right. I'm new to python and its technicality, Im used to compiled languages C/C++. But still a virtual machine inside a virtual machine is not going to be the fastest thing ever, and can probably compete to be the slowest ever way to execute code. For sure its has its utility. I don't hate on Python nor Android, but ... - user457015
(9) @user457015 I think you should really read up on how modern JVMs are implemented, they're nowhere near to "scripting" or "interpretation" by now. If anything, Java is now only ~ 10-25% slower than well / perfectly written C/C++ code. And there's way less place to screw up writing in Java... - TC1
(2) @Carlos if we're being pedantric, Android was named after its creator, Andy Rubin, and his nickname. Also, the logo for Python is a picture of two snakes (cf and the logo for Android is a picture of a robot. Since logos are often seen as an embodiment of the thing they represent, I think we can let this one slide. - LangeHaare
(1) @LangeHaare "pedantic" :-) - Carlos
[+762] [2011-11-18 21:49:45] JohnMudd [ACCEPTED]

One way is to use Kivy [1]:

Open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps.

Kivy runs on Linux, Windows, OS X, Android and iOS. You can run the same [python] code on all supported platforms.

Kivy Showcase app [2]


(35) If you use Kivy, here is a tool to help package your project into an APK: - gdw2
(8) @e-satis did Kivy work out for you? was it useful? I would be really thankful if you could post your experiences with Kivy in my question :) - juliomalegria
@julio Never had the chance to test it. We mostly do web app using jquery mobile instead. - e-satis
(10) I've been playing around with Kivy this past week attempting to write a game. Their main developers were very quick to answer questions on IRC however if you've programmed a GUI before Kivy will make you say WTF quite a bit. Some examples of undocumented things that were weird for me: All widgets get every on_touch_down event even if the event occurred outside their region, No widget has a draw() method, almost everything happens via a custom observer pattern on custom Properties they made up (note these share the name with Python's property, but are not the same) - Trey Stout
(4) @Trey: What about non-GUI-related things? Are there any limitations regarding usage of Python's modules? What about access to Android-specific features, such as ability to read messages, add notification, work in the background, make a photo, read contacts list, determine GPS location etc.? - Tadeck
(5) And now there is iOS support too! - rubik
(11) Now, almost a full year later, is support any better? Has here been any notable improvements? - TankorSmash
(12) And another year, damn google, with all the python they seem to love with websites, there's no love for python in Android. - Dexter
What are the restrictions of using Kivi ? - android developer
(2) To answer the old question of @Tadeck: Kivy has direct access to Android-specific features via pyjnius and (for a more pythonic wrapper) plyer. You can also use just about any pure python module, or modules with compiled components if you write (or there already exists) a python-for-android recipe - we already have recipes for many popular modules such as numpy, sqlalchemy and even django. - inclement
Any one know what licence it has. I see nothing on the web site (maybe I am looking it the wrong place). - ctrl-alt-delor
[+294] [2009-06-10 05:24:29] Heat Miser

There is also the new Android Scripting Environment [1] (ASE/SL4A) project. It looks awesome, and it has some integration with native Android components.

Note: no longer under "active development", but some forks may be.


(61) True, but they have to have ASE installed, it's not a solution that lets you write an Android app in python without anything already installed (normal user will be all "wtf is this ASE thing?) - Stuart Axon
(18) Further, ASE is a restricted environment; you cannot write full-blown Android apps even if ASE is pre-installed. See - Sridhar Ratnakumar
(8) I think it was renamed to SL4A. - Vanuan
(6) You can write apps, package them, and even sell them on Play Store if you like, with SL4A now days. It's come along well since the comments above were posted. If you want Python on Android, then PY4A, which runs on SL4A is probably the best choice. - Carl Smith
I confirme, SL4A now permits to write packages of application ready to use, I tried with perl it works - ubugnu
[+175] [2009-06-10 05:13:13] unmounted

YES! [1]

An example via Matt Cutts [2] via SL4A -- "here’s a barcode scanner written in six lines of Python code:

import android
droid = android.Android()
code = droid.scanBarcode()
isbn = int(code['result']['SCAN_RESULT'])
url = "" % isbn
droid.startActivity('android.intent.action.VIEW', url)

(36) s/YES/meh. maybe/'s extremely limited. anything graphical or multi touch? a big NO. - gcb
(1) @gcb you can't use the normal android widget set, but you can use "webviews" (which is what the native gmail application uses, for example). - gdw2
(16) golfed: import android as a;d=a.Android();d.startActivity('android.intent.action.VIEW'‌​,"http://books.googl‌​"%int(‌​anBarcode()['result'‌​]['SCAN_RESULT'])) - Alex L
(4) @gdw2, surely the native Gmail app only uses WebViews to parse emails though, not for the actual UI. That makes the comparison a bit absurd. - Veselin Romić
[+71] [2011-05-26 09:21:31] Rab Ross

There's also SL4A [1] written in large by Google employees.


[+68] [2011-01-28 12:18:47] muriloq

"The Pygame Subset for Android [1] is a port of a subset of Pygame functionality to the Android platform. The goal of the project is to allow the creation of Android-specific games, and to ease the porting of games from PC-like platforms to Android."

The examples include a complete game packaged in an APK, which is pretty interesting.


(3) Several aspects were broken on my Droid X (buttons, or touchscreen, can't remember), so I didn't get very far with this route. - gdw2
[+61] [2011-10-12 13:49:09] gabomdq

I've posted instructions and a patch for cross compiling Python 2.7.2 for Android, you can get it at my blog here:

EDIT: I've open sourced Ignifuga [1], my 2D Game Engine, it's Python/SDL based and it cross compiles for Android. Even if you don't use it for games, you might get useful ideas from the code and the builder utility (named Schafer, after know who).


(1) Impressive. +1 for this. Not accepted because you can't possibly write anything for the public with this. - e-satis
If you mean you can not do graphic apps with it, you most definitely can, of course, more work is needed. I actually use this port combined with SDL 1.3, it's not trivial to go from the python interpreter to an interactive app, but it can be done. - gabomdq
[+53] [2012-03-19 15:45:27] Carl Smith


Scripting Layer for Android [1] does what you want. You can easily install it directly onto your device from their site, and do not need root.

It supports a range of languages; Python is the most mature. By default, it uses Python 2.6, but there is a 3.2 port [2] you can use instead. I have used that port for all kinds of things on a Galaxy S2 and it worked fine.


SL4A provides a port of their android library for each supported language. The library provides an interface to the underlying Android API through a single Android object.

import android
droid = android.Android()

# example using the text to speech facade
droid.ttsSpeak('hello world')

Each language has pretty much the same API. You can even use the JavaScript API inside webviews.

var droid = new Android();
droid.ttsSpeak('hello from js');

User Interfaces

For user interfaces, you have three options:

  • You can easily use the generic, native dialogues and menus through the API. This is good for confirmation dialogues and other basic user inputs.
  • You can also open a webview from inside a Python script, then use HTML5 for the user interface. When you use webviews from Python, you can pass messages back and forth, between the webview and the Python process that spawned it. The UI will not be native, but it is still a good option to have.
  • There is some support for native Android user interfaces, but I am not sure how well it works; I just haven't ever used it.

You can mix options, so you can have a webview for the main interface, and still use native dialogues.


There is a third party project named QPython [3]. It builds on SL4A, and throws in some other useful stuff.

QPython gives you a nicer UI to manage your installation, and includes a little, touchscreen code editor, a Python shell, and a PIP shell for package management. They also have a Python 3 port. Both versions are available from the Play Store, free of charge. QPython also bundles libraries from a bunch of Python on Android projects, including Kivy, so it is not just SL4A.

Note that QPython still develop their fork of SL4A (though, not much to be honest). The main SL4A project itself is pretty much dead.


Can you use any of those to run python script from terminal or tasker? I can't find a way :( - Pitto
You can launch an SL4A script from Tasker. There are some examples on this page that have snippets of Python being launched from Tasker. It is really a whole different question though. - Carl Smith
[+52] [2008-11-01 20:29:44] lacker

As a Python [1] lover and Android programmer, I am sad to say this is not really a good way to go. There are two problems.

One problem is that there is a lot more than just a programming language to the Android development tools. A lot of the Android graphics involve XML files to configure the display, similar to HTML. The built-in java objects are really integrated with this XML layout, and it's a lot easier than writing your own code to go from logic to bitmap.

The other problem is that the G1 (and probably other Android devices for the near future) are really not that fast. 200 MHz processors, and RAM is very limited. Even in Java you have to do a decent amount of rewriting-to-avoid-more-object-creation if you want to make your app perfectly smooth. Python is going to be too slow for a while still on mobile devices.


(41) There is not a single java word on an Android phone, it's compiled to byte code during the packaging process. Speed is not the issue : Google could provide tools producing the right byte code from a python code (like for Jython). BTW, Dalvik is not the Java VM so this is not about Java VS Python. - e-satis
(92) Hehe. 200 MHz... 4 years later and now phones have quad-core processors... LOL. - Touzen
(3) JAVA bytecode still needs to be processed by a JVM, and the Java language requires a garbage collector anyway. Actual speed could only come from C++. - LtWorf
(15) @Touzen 2 more years later, we are running Intel Atom processor or octa-core processors now. ;) - Rohan Kandwal
(1) Due to the difference in the power they are able to draw, phones will always be an order of magnitude slower than desktops. However, don't give up on Python for the mobile device, because typically only a fraction of the code is responsible for the processor-intensive work, and this fraction can be optimised by rewriting it in another language. - Evgeni Sergeev
(1) 2017 and 8GB of RAM is a reality. - Pedro Paulo Amorim
[+30] [2008-09-19 13:26:53] Ilya Kochetov

Not at the moment and you would be lucky to get Jython to work soon. If you're planning to start your development now you would be better off with just sticking to Java for now on.

[+26] [2012-01-06 14:34:25] gdw2

Using SL4A (which has already been mentioned by itself in other answers) you can run [1] a full-blown web2py [2] instance (other python web frameworks [3] are likely candidates as well). SL4A doesn't allow you to do native UI components (buttons, scroll bars, and the like), but it does support WebViews [4]. A WebView is basically nothing more than a striped down web browser pointed at a fixed address. I believe the native Gmail app uses a WebView instead of going the regular widget route.

This route would have some interesting features:

  • In the case of most python web frameworks, you could actually develop and test without using an android device or android emulator.
  • Whatever Python code you end up writing for the phone could also be put on a public webserver with very little (if any) modification.
  • You could take advantage of all of the crazy web stuff out there: query, HTML5, CSS3, etc.

(1) Cherrypy works well, with ws4py websocket support. Bottle is also fine on SL4A. - Carl Smith
[+25] [2015-01-13 02:08:57] Anzel


I want to post this as an extension of what @JohnMudd has already answered (but please bear with me as English isn't my first language)

It has been years since then, and Kivy has evolved to v1.9-dev. The biggest selling point of Kivy, in my opinion, is its cross-platform compatibility. You can code and test under your local environment (Windows/*nix etc.), you can also build, debug and package your app to run on your Android/iOS/Mac/Windows devices.

With Kivy's own KV [1] language, you can code and build the GUI interface easily (it's just like Java XML, but rather than TextView etc., KV has its own ui.widgets for the similar translation), which is in my opinion quite easy to adopt.

Currently Buildozer [2] and python-for-android [3] are the most recommended tools to build/package your apps. I have tried them both and can firmly say that they make building Android apps with Python a breeze. Users who feel comfortable in their console/terminal/command prompt should have no problems using them, and their guides are well documented, too.

Furthermore, iOS is another big selling point of Kivy, provided that you can use the same code base with little changes required to test-run on your iOS device, via kivy-ios [4] Homebrew tools, although Xcode is required for the build before running on their devices (AFAIK the iOS Simulator in Xcode currently doesn't work for the x86-architecture build). There are also some dependency issues which must be manually compiled and fiddled around with in Xcode to have a successful build, but they wouldn't be too difficult to resolve and people in Kivy Google Group [5] are really helpful too.

With all being said, users with good Python knowledge should have no problem picking up the basics in weeks (if not days) to build some simple apps.

Also worth mentioning is that you can bundle (build recipes) your Python modules with the build so users can really make use of many existing libraries Python bring us, like Requests [6] & PIL [7] etc. through Kivy's extension support [8].

Sometimes your application requires functionality that is beyond the scope of what Kivy can deliver. In those cases, it is necessary to resort to external software libraries. Given the richness of the Python ecosystem, there is already a lot of software libraries that you can simply import and use right away.

The last but not the least, if you are going to use Kivy for more serious/commercial projects, you may find existing modules not satisfactory. There are some workable solutions though, with the "work in progress" of pyjnius [9] for Android, and pyobjus [10]. Users can now access Java/Objective-C classes through those modules to control some of the native APIs.

My experience in Kivy is that it will find its best fit with seasoned Python programmers and some serious programmers who want rapid development or simple code base maintenance. It runs well on multiple platforms, albeit not really with the native feeling.

I do hope some Python app programmers find this information useful and start taking a look at Kivy. It can only get better (with more support and as libraries/modules get ported) if there is great interest from the community.

P.S. I have no relationship with Kivy whatsoever, I'm merely a programmer who really likes the idea of bringing Python coding fun to mobile/cross-platform development.


I just downloaded Kivy from its site. Shows support for Python 3.4 32 and 64-bit, and a demo of touch input working. - codeReview
(1) @codeReview, I have been using Kivy with Python2 only and have no experience in it with Python3, is everything running smoothly? - Anzel
I will let you know hopefully soon. But I have no experience with Python outside of CPython 3.4 command shell .py files for quickly solving computation or algorithmic problems. This will be my first app with a GUI. I'd need to read more documentation, to understand the Kivy language, and to carefully follow installation steps, so I know how to install Kivi to my Python IDE of choice and packaging the APK to push to Android. The is a many-step process, so it's may not be incredibly soon when I can say. - codeReview
(1) @codeReview, good luck for your journey. If this is your first app, I strongly recommend to use .kv as layout file. It's like a yaml or simply tree file to define the layout widgets. If your app is multi-screen/layouts, use ScreenManager as this will save you tons of time. Also a piece of advice is to read their mailing list, a bunch of knowledgeable people there willing to help you. - Anzel
(1) @codeReview, also, instead of learning from Kivy's demo app, you may gain more insights searching for some existing kivy apps and see how people manage the "widgets" and callbacks in a real-world scenario. Kivy isn't hard to learn at all, I'll say much easier in terms of learning curve than say, in Java+Android or objective-C+iOS - Anzel
[+18] [2013-06-12 19:46:35] kyle k

I use the QPython application. It has an editor, a console, and you can run your Python programs with it. The application is free, and the link is

(2) Now qpython added Django support! That's all that I need! Amazing! - swdev
[+17] [2012-01-09 04:46:53] gdw2

From the Python for android [1] site:

Python for android is a project to create your own Python distribution including the modules you want, and create an apk including python, libs, and your application.


(1) Duplicate of a duplicate. - e-satis
(1) @e-satis: Thanks for your comment. I don't see which answer I'm duplicating. I can only guess that you think PFA is the same as Kivy. Though it's hosted under the Kivy project, you don't even have to use Kivy to use PFA. - gdw2
Check @tito's deleted answer at the bottom point to PFA. Plus, there is little interest is running PFA without kivy since it's the only toolkit you got. - e-satis
It's not because kivy is currently the only toolkit available (some people are working to intregrate others) than it's a duplicate. Please consider the others options as-it, and not merge all into one post :| - tito
[+14] [2012-05-09 15:44:49] e-satis

Yet another attempt:

This one embed directly the Python interpretter in your app apk.

[+13] [2018-01-23 11:58:08] Umer Farooq

There are several ways to use Python on Android.

BeeWare [1] is a collection of tools for building native user interfaces

Chaquopy [2] is a plugin for Android Studio's Gradle-based build system.

Kivy [3] is a cross-platform OpenGL-based user interface toolkit.

pyqtdeploy [4] is a tool for deploying PyQt applications.

QPython [5] is an on-device script engine and development environment.

SL4A [6] (Scripting Layer for Android), originally named ASE (Android Scripting Environment), is a set of "facades" which expose a greatly-simplified subset of the Android API.

PySide [7] (the Python binding for the Qt toolkit) has some preliminary support for Android.

Although Android's primary programming language is Java, there is no known port of Jython to the platform. Android support in BeeWare is achieved using VOC, a tool that compiles Python source code to Java class files. This allows Python code to be executed as a native binary on the JVM.


(2) IMO, this deserves more upvotes as it is clearly a more thorough answer than the accepted answer. - Agi Hammerthief
It's also been a decade since the question was first asked but I concur.! - mkingsbu
(1) There's also - frmdstryr
[+8] [2013-03-11 09:36:58] Hitul

You can run your Python code using sl4a [1]. sl4a supports Python, Perl [2], JRuby [3], Lua [4], BeanShell, JavaScript, Tcl [5], and shell script.

You can learn sl4a Python Examples [6].


[+7] [2011-03-29 16:42:06] fooba

There's also python-on-a-chip possibly running mosync: google group [1]


[+7] [2015-02-25 13:04:47] GR Envoy

Another option if you are looking for 3.4.2 or 3.5.1 is this archive on GitHub.

Python3-Android 3.4.2 [1] or Python3-Android 3.5.1 [2]

It currently supports Python 3.4.2 or 3.5.1 and the 10d version of the NDK. It can also support 3.3 and 9c, 11c and 12

It's nice in that you simply download it, run make and you get the .so or the .a

I currently use this to run raw Python on android devices. With a couple modifications to the build files you can also make x86 and armeabi 64 bit


[+7] [2017-01-20 11:36:47] Adrian Stanculescu

You can use Termux [1] application:

Note that apt install python install python 3. for python 2 you shoud call apt install python2.

Some demos here:

And also the github page:


[+6] [2014-10-06 14:59:14] radix07

Didn't see this posted here, but you can do it with Pyside and Qt now that Qt works on Android thanks to Necessitas.

It seems like quite a kludge at the moment but could be a viable route eventually...

[+5] [2016-09-16 02:41:18] ode2k

You can use QPython:

It has a Python Console, Editor, as well as Package Management / Installers

It's an open source project with both Python 2 and Python 3 implementations. You can download the source and the Android .apk files directly from github.

QPython 2:

QPython 3:

[+5] [2017-04-15 14:09:33] Pzy64

There is an app called QPython3 in playstore which can be used for both editing and running python script.

Playstore link [1]

Another app called Termux in which you can install python using command

pkg install python

Playstore Link [2]


using Termux you can install python 2 as well $ apt install python2 - M.Hefny
[+3] [2015-05-18 01:56:41] Andrzej Pronobis

One more option seems to be pyqtdeploy [1] which citing the docs is:

a tool that, in conjunction with other tools provided with Qt, enables the deployment of PyQt4 and PyQt5 applications written with Python v2.7 or Python v3.3 or later. It supports deployment to desktop platforms (Linux, Windows and OS X) and to mobile platforms (iOS and Android).

According to Deploying PyQt5 application to Android via pyqtdeploy and Qt5 [2] it is actively developed, although it is difficult to find examples of working Android apps or tutorial on how to cross-compile all the required libraries to Android. It is an interesting project to keep in mind though!


[+1] [2018-02-16 17:12:15] mhsmith


Chaquopy [1] is a plugin for Android Studio's Gradle-based build system. It focuses on close integration [2] with the standard Android development tools.

  • It provides complete APIs to call Java from Python [3] or Python from Java [4], allowing the developer to use whichever language is best for each component of their app.

  • It can automatically download PyPI packages [5] and build them into an app, including selected native packages such as NumPy.

  • It enables full access to all Android APIs from Python, including the native user interface toolkit ( example pure-Python activity [6]).

This is a commercial product, but it's free for open-source use and will always remain that way.

(I am the creator of this product.)


[0] [2018-01-12 18:56:16] DrawT

Take a look at BeeWare [1]. At the moment of answering this question it is still in early development. It's aim is to be able to create native apps with Python for all supported operating systems, including Android.