我在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
相关信息:
问题:
有谁知道造成这种情况的原因是什么?提前谢谢!
答案 0 :(得分:1)
事实证明,这个问题的根源是相当普遍的。找不到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
<强>解决方案:强> 将'/ usr / local / lib'添加到'/etc/ld.so.conf'并运行ldconfig。
答案 1 :(得分:0)
...使用Mapnik 3和Tile Stache 保持2018年8月22日的流程,但出现了几乎相同的错误。接受的答案对我没有帮助,事实证明,Mapnik Python bindings are installed separately是最新版本。
看着here,我可以从命令行运行,很简单:
pip install mapnik
这解决了我的问题,因此我可以运行python解释器并导入mapnik。
一个潜在的警告。 Mapnik的新闻页面提到pip安装使用了“ Python Wheels”,如果您检查链接的页面,则提到需要pip> = 1.4。您可以在命令行上使用pip --version
检查您的点,而我的点是7.1.2。因此,对于大多数人来说,这是个无关紧要的问题。