Python for Android

I knew it was just a matter of time when someone ports python to Android. Kudos to Google employee Damon Kohler, who decided to built SL4A – Scripting Layer For Android in his 20% time that Google allows their employees to work on “pet projects”. Not only that SL4A supports python, other contributors ported some other popular interpreters to SL4A, such as Perl, JRuby, JavaScript, Lua, BeanShell and Tcl…more interpreters are on the way.
Linux Journal published interesting article in March issue, #204, titled “Python for Android”.
I’m happy to report that installing SL4A and python for Android on my HTC Hero (running Android 2.1) as described in the above article was trivial.

Here are the steps on how to install SL4A and Python for Android on HTC Hero (with OS 2.1):

  • Temporary enable installation of applications from unknown sources
    Menu -> Settings -> Applications -> check "Unknown sources"

    HTCUnknownSources

  • open Android web browser on your HTC phone and go to http://code.google.com/p/android-scripting/.
    If you tap on “QR Code” on the web page you’ll start downloading SL4A, at the time of this writing it was sl4a_r3.apk.
    After download completes, simply tap the downloaded apk package, then tap on Install button. This will install SL4A on your phone. Test the installation by tapping on Open button to open SL4A. If you receive warning “No matches found” simply ignore it, because you don’t have any script yet.
    Now, that we have SL4A “engine” ready, it’s time to install Python itself.
  • return to Android web browser and open the page http://code.google.com/p/android-scripting/. Find “Featured Downloads” section on left side of the page, then find the package PythonForAndroid_r4.apk. Tap the package to initiate the download, when download completes tap the package to start installation by tapping “Install button”.
    When installation completes tap the “Open button” followed by tap on Install button. This will download and install python support libraries from SL4A web site and add them to SL4A.
    HTC-Python
  • That’s it. If you check your Applications you’ll see two new icons, “Python for Android” and “SL4A”. At the time of this writing, python version was 2.6.2.
    HTCPythonForAndroid
  • If you open SL4A you should see some pre-created python demo scripts on the list.
    HTC-SL4A

  • If you tap on the particular script you can pick action from the menu.
    HTC-SL4A-menu

  • For example, you can Edit the script.
    HTC-SL4A-edit

  • Finally, don’t forget to disable option that allows installing applications from unknown sources (see point #1).

Posted on 06.03.2011, in Scripting and tagged , , . Bookmark the permalink. Comments Off on Python for Android.

Comments are closed.