Sometimes, you may find that PIL is overkill for your purposes, or you are not allowed to install PIL because you do not have administrative rights to the machine that you're using to install Python modules that have been created and compiled in C. In those cases, you can usually get away with the lightweight pure Python PNGCanvas module. You can install it using easy_install or pip.
Using this module, we can repeat the raster shapefile example we performed using PIL but in pure Python, as you can see here:
>>> import shapefile
>>> import pngcanvas
>>> r = shapefile.Reader("hancock.shp")
>>> xdist = r.bbox[2] - r.bbox[0]
>>> ydist = r.bbox[3] - r.bbox[1]
>>> iwidth = 400
>>> iheight = 600
>>> xratio = iwidth/xdist
>>> yratio = iheight/ydist
>>> pixels = []
>>> for...