I set up a TileStache server on Redhat, installing Mapnik 2.2 from source. However, Tilestache is giving me the following error:
Traceback (most recent call last):
File "/usr/lib64/python2.6/site-packages/gevent/pywsgi.py", line 508, in handle_one_response
self.run_application()
File "/usr/lib64/python2.6/site-packages/gevent/pywsgi.py", line 494, in run_application
self.result = self.application(self.environ, self.start_response)
File "/usr/lib/python2.6/site-packages/TileStache/__init__.py", line 381, in __call__
status_code, headers, content = requestHandler2(self.config, path_info, query_string, script_name)
File "/usr/lib/python2.6/site-packages/TileStache/__init__.py", line 254, in requestHandler2
status_code, headers, content = layer.getTileResponse(coord, extension)
File "/usr/lib/python2.6/site-packages/TileStache/Core.py", line 414, in getTileResponse
tile = self.render(coord, format)
File "/usr/lib/python2.6/site-packages/TileStache/Core.py", line 500, in render
tile = provider.renderTile(width, height, srs, coord)
File "/usr/lib/python2.6/site-packages/TileStache/Goodies/Providers/MapnikGrid.py", line 72, in renderTile
self.mapnik = mapnik.Map(0, 0)
NameError: global name 'mapnik' is not defined
Relevant Information:
- Other posts have suggested changing 'import mapnik' to 'import mapnik2 as mapnik'. But I got the same error message.
- In other posts originates from TileStace/Mapnik.py, but mine comes from TileStache/Goodies/Providers/MapnikGrid.py.
- Related Post: Gunicorn fails when using WSGI
Question:
Does anyone know what could be causing this? Thanks in advance!
It turns out the root of this problem is fairly common. The libmapnik shared library was not found.
When I tried to import mapnik from the python console I received this error:
Which led me to the answer here: https://github.com/mapnik/mapnik/wiki/InstallationTroubleshooting#the-libmapnik-shared-library-is-not-found
Solution: Add '/usr/local/lib' to '/etc/ld.so.conf' and run ldconfig.