我在Redhat上设置了TileStache服务器,从源代码安装了Mapnik 2.2。但是,Tilestache给了我以下错误:
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
相关信息:
其他帖子建议将“导入mapnik”更改为“将mapnik2作为mapnik导入”。但是我得到了同样的错误信息。
其他帖子来自TileStace / Mapnik.py,但我的帖子来自TileStache / Goodies / Providers / MapnikGrid.py。
相关文章:Gunicorn fails when using WSGI
题:
有谁知道是什么原因造成的?提前致谢!
最佳答案
事实证明,这个问题的根源相当普遍。找不到libmapnik共享库。
当我尝试从python控制台导入mapnik时,出现以下错误:
>>> import mapnik
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/site-packages/mapnik/__init__.py", line 69, in <module>
from _mapnik import *
ImportError: libmapnik.so.2.2: cannot open shared object file: No such file or directory
这导致我在这里回答:
https://github.com/mapnik/mapnik/wiki/InstallationTroubleshooting#the-libmapnik-shared-library-is-not-found
解:
将“ / usr / local / lib”添加到“ /etc/ld.so.conf”并运行ldconfig。
关于python - 使用Tilestache时未定义全局名称“mapnik”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25450026/