Skip to content Skip to sidebar Skip to footer

Gunicorn Fails When Using Wsgi

I want Gunicorn to talk with TileStache via WSGI. But when I run this command... gunicorn 'TileStache:WSGITileServer('/var/osm/bright/project/OSMBright4/tilestache.cfg')' ...I get

Solution 1:

Do you have python-mapnik installed? The error appears to be in the configuration of TileStache and mapnik rather than gunicorn or WSGI. If you look at TileStache/Mapknik.py (I am looking here: https://github.com/migurski/TileStache/blob/master/TileStache/Mapnik.py), you see that the initial import of mapnik passes on the error:

try:
    import mapnik
except ImportError:
    # can still build documentationpass

but that will cause problems in line 81 when mapnik is expected to be there. So, make sure you apt-get install python-mapnik or otherwise ensure mapnik is in your Python path.

Solution 2:

Problem solved.

It came up, as Karmel mentioned, that the problem lay in Mapnik and TileStache, and not Gunicorn.

After some research I found out that there has been changes of the python module name through the different versions; it was mapnik until version 2.0 when it changed to mapnik2, and then back to mapnik again at version 2.1. And obviously it appeared that I had installed version 2.0.

I suppose I just could have changed to import mapnik2 in TileStache/mapnik.py, but I thought it would be more future friendly to uninstall Mapnik and then build it from source instead. It took a while, but definitely worth it.

A big thanks to Karmel for putting me at the right track!

Post a Comment for "Gunicorn Fails When Using Wsgi"