Is there a way to run Python on Android?

ID : 419

viewed : 117

Tags : androidpythonjythonaseandroid-scriptingandroid

Top 5 Answer for Is there a way to run Python on Android?

vote vote

100

One way is to use Kivy:

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

vote vote

86

There is also the new Android Scripting Environment (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.

vote vote

73

Yes! : Android Scripting Environment

An example via Matt Cutts 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 = "http://books.google.com?q=%d" % isbn droid.startActivity('android.intent.action.VIEW', url) 
vote vote

70

Pygame Subset for Android

Pygame is a 2D game engine for Python (on desktop) that is popular with new programmers. The Pygame Subset for Android describes itself as...

...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 as an APK, which is pretty interesting.

vote vote

54

As a Python lover and Android programmer, I'm sad to say this is not 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 integrated with this XML layout, and it's a lot easier than writing your code to go from logic to bitmap.

The other problem is that the G1 (and probably other Android devices for the near future) are 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.

Top 3 video Explaining Is there a way to run Python on Android?

Related QUESTION?