The more I've learned about Python, The more I've heard about several external libraries that are available, and I was wondering what are some of your favorite python libraries that are availible.

A few of my favorites I've discovered:

  • Beautiful Soup - for scraping web sites
  • PyGame - for game development
  • MySQLdb - for interacting with a MySQL database. absolutely essential for some projects.

so what are some of your favorites?

+5  A: 

I also state PyGame but for another reason. I do use it for the occasional game development fix but I also find it very, very useful for all kinds of interactive and/or dynamic visualizations.

A good example of this was the original Psyco presentation, written entirely in PyGame: (see "Animated slides")
Didnt know about that one, thanks! Ill check it out.
+22  A: 
  • Twisted, event-driven framework very useful for writing asynchronous network services.
  • Django, the favorite MVC web application framework of many Python developers.
  • Numpy, a fast math library for performing limited-precision calculations on large arrays/matrices.
+1, especially for Numpy
+1 for twisted, it's really amazing
Bryan McLemore
+1 for django. It had to be said. :)
+6  A: 

PIL is my favorite.

PIL 1.1.7 is about to be released. It will be available to Python 3.

Nadia Alramli
+1. It's a bit old and untended of late, but still effective and much more pleasant to use than any of the Java graphics stuff.
No thanks, I use Pycairo for my graphics needs. Quite efficient, supports native output to SVG and hardware acceleration for live displays.
@intgr pycairo != PIL. Sure pycairo is better for 2D graphics. But you can't do image processing with pycairo.
Nadia Alramli
+10  A: 

For my work it has to be numpy and scipy, with matplotlib coming in a close second. Traits and Pytables are also strong contenders!

+1 for scipy. It is awesome!
+5  A: 
  • for the web >> (you literally write: import web)
  • and for the DB >> sqlalchemy
nice, I'll have to check out webpy. I've been wanting to do some web based stuff with python, but I didn't want to use a full-blown framework like Django. looks really nice.
+8  A: 

Parallel Python, for being the easiest way I've found to utilize multiple processor cores and distribute my data analysis tasks across multiple machines.

How is that different from multiprocessing? It seems to just be a wrapper around using different processes.
Jason Baker
I believe you're right, but what I wanted to do (just speed up my existing data analysis code by farming it out to lab computers) required like two additional lines of code with parallelpython, so I went with that. I'll learn multiprocessing eventually.
@Jason - multiprocessing is just on a single machine - parralel python allows you to distribute jobs to many machines (ie a cluster)
+2  A: 

I'm partial to pysistence. Of course, that could have something to do with the fact that I wrote it.

Jason Baker
+1 for full disclosure :)
+8  A: 

I am going to nominate these:

  • lxml - ok, we all know, that built-in xml support is terrible (yes, it is).
  • pexpect. It is not crossplatform, though.
  • pyparsing

And django, of course.

+1 for lxml, the only *great* XML parsing library
intgr for "pexpect for Windows".
Alex Martelli
Hmm, I've just skimmed through the source and the first thing that caught my eye was this: first some stuff is imported in a try block, ImportError is then caught and reraised with the following text appended: "A critical module was not found. Probably this operating system does not support it. Pexpect is intended for UNIX-like operating systems." I mean, "pexpect for Windows", indeed. Ok, this obviously is a leftover from the original module (since it clearly imports win32 stuff), but still :P
+6  A: 

Python for Windows extensions is useful for Windows users.

Nick D
+6  A: 
oh I forgot about this one. I haven't played around with it yet, but it looks really cool.
+2  A: 
Corey Goldberg
+3  A: 

Two I commonly end up using are:

Suds - for SOAP related web service calls:

Psycopg - for Python-PostgreSQL database work:

+9  A: 

My favorites are

Note: I use Werkzeug/SQLAlchemy/Jinja2/WTForms as a mix for MVC web development. We also use a light weight framework named Gypsy to tie those together.

Also I don't think I'd ever want to change my db scheme without SqlAchemy Migrations I can't express enough how much easier it makes my life when it comes to deployment time (or when it's time to revert!).

Bryan McLemore
  1. PyGame: already mentioned before, but worth mentioning again.
  2. PyCrypto: great for cryptography, also has a handy probabilistic prime checker.
+9  A: 

I nominate antigravity.

kind of getting old.
Old doesn't mean bad. Just means it's turning into a classic. :)
+4  A: 

pyinotify allows you to write programs which react to changes in the filesystem. It can alert you when mail arrives, or recompile a program or TeX document every time it changes. It can process files as they are dropped into a directory.

pyinotify uses Linux's inotify mechanism, however, so it only works with Linux.

+3  A: 

For building desktop GUI apps both wxPython and PyQt are excellent.

IMHO PyQt is more polished but is not open source for commercial use (it is for non-commercial use though).

Nokia (owners of Qt) are working on Pyside, a fully open-source competitor to PyQt.

Dave Kirby
+10  A: 

dateutil - Everything that the standard Python Date library lacks.


lxml. Fantastic. Does everything you need for XML/HTML manipulation (and it's fast).

+1  A: 

I use PIL, python-twitter, django, simplejson, BeautifulSoup, and django-tagging often in projects. I highly recommend each of them.

+1  A: 

Almost all my favorites have already been mentioned, but not yet some specialized ones such as pytz (best way to handle timezones) and pymox (for testing in the mock-objects way).

Alex Martelli
+1  A: 


+1  A: 

To add some that others have not mentioned:

  • South (for data migrations in Django)
  • Psyco (for instantly improving the performance of Windows python scripts 5-10 times)

To reiterate other packages:

  • Django
  • Twisted
  • BeautifulSoup
  • MySQLdb
  • Fabric
  • dateutil
  • PIL
  • Numpy and scipy
  • Natural Language Toolkit (NLTK)
5-10 times improvement in Psyco is clearly an overstatement. In many non-algorithmic applications, you're lucky to get better-than-native speed, even 2x is too much to expect.
+3  A: 

For when you need to quickly read or write an Excel file, has some excellent modules. These modules don't require Windows or COM objects!

Eric Palakovich Carr

The ones I use frequently:

  • zope 3
  • Python Imaging Library
  • reportlab (and z3c.rml)
  • Sphinx (its a tool not a library)
  • elementtree
  • wxPython
Shailesh Kumar
+2  A: 

I'm very fond of opster. It makes turning a collection of functions into a command-line script a breeze. There are many players in this area, but its command and argument definition is very similar to how Mercurial does it, which in my opinion is excellent.

+3  A: 

I use the following:

pyserial - cross-platform serial port access; simple to use and very stable. This should be added to the default python libraries!

pygtk - python interface for GTK+, an API for cross-platform GUI apps. Works great with Glade for rapid development and testing of user interfaces.

I definitely agree with the pyserial recommendation. I do embedded work and it is awesome to have a powerful, cross-platform serial library. Now if windows would allow you to select on a file descriptor all would be well with the world.
Paul Osborne
+1  A: 

A lot of my favorites have already been mentioned.

Still I would like to nominate:

  • mod_wsgi A great project to connect your Python web applications to Apache
  • pyclutter With these Python bindings for Clutter you can create cool OpenGL powered applications easily
Daan Davidsz
+2  A: 
  • PyQt - the best GUI toolkit bindings for the best GUI toolkit in the world
  • Docutils (for restructured text processing) - an excellently designed library
  • pyserial - great serial (COM) port bindings
  • Pygame
  • PyYAML - I really like the YAML format, and PyYAML is a good, fast binding for it
  • PLY - for coding complex lexers and parsers easily
Eli Bendersky

rdflib for manipulation of rdf data.

Stefano Borini

I like the Mako template engine a lot, it's great for generating content out of templates for HTML or just about any other type of document, really.


I use

  • psyco - just-in-time (JIT) compiler
  • py2exe - to make standalone executable files in windows.

also using wxPython, MySQLdb, and PIL too.

and sometimes built my own when speed does matter, with C/C++ - Extending Python with C or C++

  • PyCrypto, I like the easy cryptography as compared to OpenSSL in C, etc.
  • My own for anything Wii related.
  • pyinstaller for creating binaries. Only one I found that works on all my OSs and is easy to use, too bad you have to use SVN.
+1  A: 

pyquery: a jquery-like library for python

Although it's not complete yet, it makes writing screen scraping scripts a lot easier if you are already familiar with jQuery.


pymssql has worked well for me lately.

+1  A: 

I work with data most of the time, and my must haves:

  • SQL/relational database work: SQLAlchemy
  • CouchDB: Couchdbkit
  • R: rpy

and for quite web prototyping,

+3  A: 

I'll throw in my 2 cents:

httplib2 - A comprehensive HTTP library, including auth, caching, all methods, redirects, compression, more. And, I can remember its API without looking up documentatiion. I can never remember exactly how urllib, urllib2 work

feedparser - very robust library for consuming RSS/Atom feeds

+2  A: 

Storm, a simple ORM library developed by Canonical.

+1  A: 

I've been working on a project where I needed to analyze some huge networks so:

NetworkX "for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks".

+2  A: 

CherryPy a pythonic, object-oriented HTTP framework.

+3  A: 

Iterpipes because I greatly dislike the interface for subprocess, especially concerining pipes.

Buildout. Incredibly weird to me at first, I can't picture python without it.