How to: Python on the iPhone/iPod touch

So, with my recent adventures with my iPod, I decided I wanted to do something.  I wanted to run Python on my iPod.  Turned out, that is not too difficult.  What’s more, I also found a good way to write Python scripts on my iPod, and then run them too.  My iPod has turned into a beast mobile programming platform.

Okay, so not really.  The screen is still pretty small and Python is only on version 2.5.1.  3.x code runs on 2.x, so all my programs still work.  Also, the mobile python doesn’t have Turtle.  But, if you want to start programming Python on your iPod/iPhone, read on!

  1. Your iDevice must be jailbroken, there is no way around this.
  2. Your Filters in Cydia must have been “Developer,” aka, no filters.  Otherwise this will not work.
  3. Go to Cydia and Search for “Python” without the quotes.  There is a package called “Python”, select it.
  4. Hit Install in the top right corner.  This is a big package, weighing in at 17-ish MB.  So make sure your iPod doesn’t go to sleep and lose internet while downloading and installing it.
  5. After installation, you won’t notice anything different, this is because it’s a console package; you need a console.  Go back to Cydia’s Search and type in “MobileTerminal.”  Select MobileTerminal.
  6. Install MobileTerminal.
  7. Now you almost have all the tools you need; to be truly set though, you need a text editor.  Go back to Cydia’s search and type in “iEdit.”  Select iEdit.
  8. Install iEdit (requires 3.x)
  9. You may now exit Cydia.  You should now have up to 2 new icons on your Screens, iEdit, and Mobile Terminal.
  10. Open iEdit.  I found that putting documents in /private/var/mobile/Documents/ is a good place because you can easily get to it and it’s not cluttering up the file system.  To make a new file, simply tap the “+” in the upper left corner.  If you are making a python script, make sure it ends in “.py“.  To save, hit “minimize” and then “save” (in the bottom left corner.)
  11. After making and saving your file, exit iEdit.
  12. Open MobileTerminal.  (Terminal)
  13. type:  cd Documents
  14. type: ls
  15. You should see the file you made, as long as you saved it in this directory.
  16. To run a python script, type in:  python (Where “” is the name of your file.)

That’s all there is to it!  Many of these instructions are very exact, but you can have a lot of fun.  For example, in iEdit make a file called “” and for a command simply type in:

print(“Hello World!”)

Then in Mobile terminal, move to the directory (cd Documents) and then type python And see the beautiful results!


~ by wayfarer247 on October 7, 2009.

12 Responses to “How to: Python on the iPhone/iPod touch”

  1. Cool! I was thinking about getting a iPod Touch, this is swaying the scales in my favor. Thanks! Bookmark’d.

  2. This is amazing!
    Perfect my for classes, I’m writing programs already!
    Thank you so much!

  3. […] a great little guide for install python on a jailbroken iTouch or iPhone: Even though this writing is immensely old, it worked! Installed Python version 2.5.1 on my G1 […]

  4. These instructions were a big help, thanks!

  5. is it python 3 or 2.x?

  6. great. thanks.

  7. Very useful! thanks!

    Question: when running python on the iphone, can you write programs that access data from iphone’s api’s like accelerometer and gyroscope?

    • I don’t think so; those are Objective-C API calls, and the Python is rather sandboxed (from what I understand). There’s no easy way to do it – but if you look at how Python calls system commands (, there’s a small, tiny, chance you could call something from the system to get that data.

      tl;dr – I don’t think so.

  8. Would’nt this allow you to make bots/macros for your iPod or?

  9. I’d update python to 2.7 so you could run sqlmap :B

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: