Python Desktop

This is a quick guide to using Python and various additional packages on a desktop machine. See PythonIpaq for using it on a PocketPC device. Note that not many of the additional packages listed here have been ported to the PocketPC


Never mind all this, just get me set up!

In a hurry to install? See QuickStartPython.


  1. What is Python?
  2. Installing
      1. Python
  3. Packages
    1. Highly Recommended
      1. Win32all
      2. Py2Exe
      3. Twisted
      4. Numeric
      5. SciPy
      6. IPython
      7. PyGame
      8. EPyDoc
      9. PIL
    2. Optimization
      1. Psyco
      2. PyRex
      3. PyInline
      4. F2Py
    3. General Development
      1. PyDispatcher
    4. 3d Stuff
      1. vpython
      2. PyOpenGl
      3. Soya3D
      4. SPyRE
      5. PyOgre
      6. PyOde
      7. QwPython
    5. GUI
      1. PythonCard
      2. WxPython
    6. Scientific
      1. MatPlotLib
    7. SimPy
      1. MayaVi
    8. Text Processing
  4. Guides
    1. Beginning
    2. More advanced
    3. Quick Start
    4. GUI
    5. Optimization
    6. Functional Programming
  5. Useful Links
    1. Jython
    2. Package Index
    3. Cookbook
    4. FAQ
    5. Modules
    6. 3D Stuff

What is Python?

From the python homepage:

"What is Python?

Python is an interpreted, interactive, object-oriented programming language. It is often compared to Tcl, Perl, Scheme or Java.

Python combines remarkable power with very clear syntax. It has modules, classes, exceptions, very high level dynamic data types, and dynamic typing. There are interfaces to many system calls and libraries, as well as to various windowing systems (X11, Motif, Tk, Mac, MFC). New built-in modules are easily written in C or C++. Python is also usable as an extension language for applications that need a programmable interface.

The Python implementation is portable: it runs on many brands of UNIX, on Windows, OS/2, Mac, Amiga, and many other platforms. If your favorite system isn't listed here, it may still be supported, if there's a C compiler for it. Ask around on news:comp.lang.python -- or just try compiling Python yourself.

The Python implementation is copyrighted but freely usable and distributable, even for commercial use"

Note: this wiki is written in Python (so it obviously can do quite a lot)! Once you've installed Python, see the Guides below for help on getting started...



Installing

Python

Available on: Desktop and PocketPC (see PythonIpaq)

Get python 2.3.5 from http://www.python.org/2.3.5/ Every other package is optional, but you really want them! For Windows, installation is extremely easy; just run the installer. The same is true for all the optional packages below, they all come with a simple windows installer.


Packages

Each package lists whether it's available for the desktop or for the PocketPC.

Highly Recommended

Win32all

Available on: Desktop and PocketPC (see PythonIpaq)

Summary: Provides access to all the windows API functions from python.

Download: http://starship.python.net/crew/mhammond/win32/

Comments: You really want to have this for a windows environment!

Py2Exe

Available on: Windows Desktop machines only -- doesn't make sense for other platforms

Summary: NOT a python module -- instead allows you to package up scripts as a single executable for end user use, without having to install all the various dependencies.

Download: http://starship.python.net/crew/theller/py2exe/

Twisted

Available on: Anything, pure python

Summary: Very sophisticated and easy to use networking code. It's efficient too.

Download: http://twistedmatrix.com/products/twisted

Numeric

Available on: Desktop only (should be possible to port this though, I'm trying)

Summary: Provides a comprehensive matlab-like set of very fast matrix and general math routines.

Download: http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=1351 (get the version for python 2.3).

SciPy

Available on: Desktop only (may be possible to port this though)

Summary: provides a vast array of scientific routines on top of Numeric -- like fft, ode solving, and a whole bunch of other stuff. See http://www.scipy.org/About/ for a quick overview. Includes Weave for optimizing code.

Download: http://www.scipy.org/download

IPython

Available on: Anything, it's just python code

Summary: Enhanced console for python. Includes syntax highlighting in the console, tab completion and so on. It's a must!

Download: http://ipython.scipy.org/dist/.

Note: For Windows users, you probably want to get Readline from http://sourceforge.net/project/showfiles.php?group_id=82407&package_id=84552 (although IPython works without out it, a huge amount of functionality is added with readline). To use readline, you must have installed win32all (above) and also CTypes from http://starship.python.net/crew/theller/ctypes/

PyGame

Available on: Desktop only (should be possible to port this though, I'm trying)

Summary: PyGame makes it extremely easy to make realtime graphical interfaces (and indeed audio ones). It's designed to be simple to use, but while remaining powerful.

Download: http://www.pygame.org/download.shtml

EPyDoc

Available on: Anything, it's pure python code

Summary: Quick and effective way to make documentation for your API's (like JavaDoc). Verbose example of it's use:

   1 def x_intercept(m, b):
   2     """
   3     Return the x intercept of the line M{y=m*x+b}.  The X{x intercept}
   4     of a line is the point at which it crosses the x axis (M{y=0}).
   5 
   6     This function can be used in conjuction with L{z_transform} to
   7     find an arbitrary function's zeros.
   8 
   9     @type  m: number
  10     @param m: The slope of the line.
  11     @type  b: number
  12     @param b: The y intercept of the line.  The X{y intercept} of a
  13               line is the point at which it crosses the y axis (M{x=0}).
  14     @rtype:   number
  15     @return:  the x intercept of the line M{y=m*x+b}.
  16     """
  17     return -b/m

The full reference can be read at http://epydoc.sourceforge.net/epytext.html

Download: http://epydoc.sourceforge.net/

PIL

Available on: Desktop only (as of yet)

Summary: Python Imaging Library, makes it easy to load and save a wide variety of bitmap graphics formats.

Download: http://www.pythonware.com/products/pil/index.htm


Optimization

Psyco

Available on: Desktop only

Summary: JIT compiler -- massively speed up Python code.

Download: http://psyco.sourceforge.net/

PyRex

Available on: Desktop only

Summary: Make very easy C extensions in python

Download: http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/

PyInline

Available on: Desktop Only

Summary: Allows you to write C code in-line in your Python programs

Download: http://pyinline.sourceforge.net/

F2Py

Available on: Desktop Only

Summary: Makes it extremely straightforward to interface Fortran code with Python (handy for all those old scientific routines...)

Download: http://cens.ioc.ee/projects/f2py2e/


General Development

PyDispatcher

Available on: Desktop only (may be portable not checked)

Summary: Event dispatcher. Useful if you need to have communicating objects inside your program (e.g. like in SIGIL).

Download: http://pydispatcher.sourceforge.net/

3d Stuff

vpython

Available on: Desktop only

Summary: Easy 3D programming with Python (+numeric)

Download: http://www.vpython.org

Note: Here's some example code that shows a ball bouncing on the ground:

   1 from visual import *
   2 
   3 floor = box (pos=(0,0,0), length=4, height=0.5, width=4, color=color.blue)
   4 ball = sphere (pos=(0,4,0), radius=1, color=color.red)
   5 ball.velocity = vector(0,-1,0)
   6 dt = 0.01
   7 
   8 while 1:
   9   rate (100)
  10   ball.pos = ball.pos + ball.velocity*dt
  11   if ball.y < ball.radius:
  12     ball.velocity.y = -ball.velocity.y
  13   else:
  14     ball.velocity.y = ball.velocity.y - 9.8*dt

PyOpenGl

Available on: Desktop only (porting this is out of the question!)

Summary: Allows you to manipulate OpenGL from Python, and includes a number of simple wrappers for common OpenGL tasks.

Download:

OK, you need a bunch of packages for this one (but it's worth it!). This . All of these have windows installers as well as UNIX versions, so they are really quick and easy to install.

Soya3D

Available on: Desktop only. Requires OpenGL

Summary: Powerful 3d engine -- makes it easy to set up 3d worlds

Download: http://thomas.paviot.free.fr/soya/

SPyRE

Available on: Desktop only (needs PyOpenGL, so not portable)

Summary: A very simple PyOpenGL=based graphics library, for quickly knocking together prototypes. Especially good for rendering particle systems. ' Download: http://pduel.sourceforge.net/spyre/

PyOgre

Available on: Desktop only

Summary: An as-yet immature but promising game development library. Very, very powerful.

Download: http://www.ogre3d.org/wiki/index.php/PyOgre

PyOde

Available on: Desktop only, port should be possible

Summary: Physics simulation. This is both powerful and simple. Here's a simple code example which creates a moving sphere:

   1 # pyODE example 1: Getting started
   2 
   3 import ode
   4 
   5 # Create a world object
   6 world = ode.World()
   7 world.setGravity( (0,-9.81,0) )
   8 
   9 # Create a body inside the world
  10 body = ode.Body(world)
  11 M = ode.Mass()
  12 M.setSphere(2500.0, 0.05)
  13 M.mass = 1.0
  14 body.setMass(M)
  15 
  16 body.setPosition( (0,2,0) )
  17 body.addForce( (0,200,0) )
  18 
  19 # Do the simulation...
  20 total_time = 0.0
  21 dt = 0.04
  22 while total_time<2.0:
  23     x,y,z = body.getPosition()
  24     u,v,w = body.getLinearVel()
  25     print "%1.2fsec: pos=(%6.3f, %6.3f, %6.3f)  vel=(%6.3f, %6.3f, %6.3f)" % \
          (total_time, x, y, z, u,v,w)
  26     world.step(dt)
  27     total_time+=dt

Download: http://pyode.sourceforge.net/

QwPython

Available on: Desktop Only

Summary: Allows you to interface with the Quake engine via Python. May be useful for prototyping

Download: http://sourceforge.net/projects/qwpython

GUI

PythonCard

Available on: All machines with wxPython (desktop only for now)

Summary: Easy to use GUI builder, good interactive debugging and editing

Download: http://pythoncard.sourceforge.net/

WxPython

Available on: Desktop only

Summary: GUI library. You might want to try this if for some reason you don't or can't use TkInter

Download: http://sourceforge.net/project/showfiles.php?group_id=10718

Scientific

MatPlotLib

Available on: Desktop only.

Summary: Matlab compatible graphing commands with various output formats (like eps, etc.) as well as on screen display.

Download: http://sourceforge.net/project/showfiles.php?group_id=80706

SimPy

Available on: Desktop only

Summary: A stochastic discrete event simulation package (e.g. for simulating queues and such like)

Download: http://sourceforge.net/project/showfiles.php?group_id=62366

MayaVi

Available on: Desktop only

Summary: Powerful visualization package.

Download: http://mayavi.sourceforge.net/

Text Processing

Available on: Probably any Python platform

Summary: Natural language toolkit: stemming, frequency tables and such.

Download: http://nltk.sourceforge.net/index.html


Guides

Beginning

Read Introduction to Python first of all. Then:

More advanced

Quick Start

GUI

Optimization

Functional Programming

* Articles on functional programming in Python: http://www-106.ibm.com/developerworks/linux/library/l-prog.html, http://www-106.ibm.com/developerworks/linux/library/l-prog2.html and http://www-106.ibm.com/developerworks/opensource/library/l-prog3.html


Useful Links

Jython

Python has been ported to Java -- i.e it will run on every machine supporting Java. See http://www.jython.org/

Package Index

Cookbook

FAQ

Modules

3D Stuff

last edited 07.05.2005 16:34:12 by John Williamson