Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
148 lines (106 sloc) 5.1 KB

Write Processing sketches in Python. Jonathan Feinberg <>

Found a bug?

See the open bugs in the bug tracker.

Quick Start

Download the distribution.

$ curl -L | tar zx
$ cd

Then try some examples.

$ java -jar processing-py.jar
$ java -jar processing-py.jar
$ java -jar processing-py.jar
$ java -jar processing-py.jar
$ cat >
def draw():
    text(frameRate, 20, 20)
$ java -jar processing-py.jar

What is this? is a system that lets you write programs in a dialect of Python that has all of these keywords.

In general, the way you run a program is to say

$ java -jar processing-py.jar path/to/

Can I use all of the existing Processing libraries?

Yes! is implemented in Java, and is meant to be compatible with the whole existing ecosystem of Processing libraries.

Put processing extension libraries in the "libraries" subdirectory of your installation.

$ curl -O
$ cd libraries
$ unzip ../

Import them in the usual Python way, as in these snippets:

import peasy.PeasyCam


import peasy.PeasyCam as PeasyCam


from peasy import PeasyCam

and then, in your setup() method

cam = PeasyCam(this, 200)

Unfortunately, from foo import * is not supported.

Use this to refer to the PApplet you're in, as in the examples above. Many libraries need a reference to "the current PApplet", and that's what this is for.

Put any Python libraries in the "libraries" directory, or in sketch directories. Only pure-Python libraries will work--nothing that requires "native" code.

Example Code

""" - demonstrate Perlin noise
  Jonathan Feinberg
srcSize = 50
destSize = 400
g = createGraphics(srcSize, srcSize, JAVA2D)

def setup():
    size(destSize, destSize, OPENGL)

def draw():
    t = .0005 * millis()
    for y in range(srcSize):
        for x in range(srcSize):
            blue = noise(t + .1*x, t + .05*y, .2*t)
            g.set(x, y, color(0, 0, 255 * blue))
    image(g, 0, 0, destSize, destSize)


I recently gave a talk about Processing to a group of rather bright 8th-graders, as part of a computer-programming summer camp they were attending at my office. Their curriculum up to that point had been in Python, which is an eminently sensible choice, given the pedagogical roots of the language.

The kids were really turned on by the demos--I showed them the white glove, and Golan Levin's New Year's cards--but they were bogged down by Processing's C-like syntax, which really seems arcane and unnecessarily complex when you're used to Python.

I shared my experience with Processing creators Ben Fry and Casey Reas, and they told me that, indeed, the original Processing was a fork of "Design By Numbers", with Python and Scheme support hacked in. Support for a multi-lingual programming environment was always part of the plan, so they were enthusiastic about any new attempt at the problem.

I was able to hack up a proof of concept in a couple of hours, and have managed to create something worth sharing in a couple of weeks. I was only able to do it at all thanks to the brilliant and beautiful Jython project.

At the time of Processing's first public release, August of 2001, Jython was too young a project to be used in this way. But now, having done absolutely no work to profile and optimize, I can get hundreds of frames per second of 3D graphics on my linux box. So, kudos to the Processing project, and kudos to Jython!

Please play with this, report bugs, and port more of the Processing examples!

A word from a sponsor

YourKit has kindly granted me a license to use their excellent Java profiler. I'm happy to give them the space to say:

YourKit is kindly supporting open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products: YourKit Java Profiler and YourKit .NET Profiler.

Something went wrong with that request. Please try again.