Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用mapnik.render(mapnik::Map,PycairoContext*)时意外崩溃_Python_Django_Cairo_Mapnik - Fatal编程技术网

Python 使用mapnik.render(mapnik::Map,PycairoContext*)时意外崩溃

Python 使用mapnik.render(mapnik::Map,PycairoContext*)时意外崩溃,python,django,cairo,mapnik,Python,Django,Cairo,Mapnik,我正在使用mapnik以PDF格式渲染地图,遇到了一个混乱的问题 def writeFile(m, mapId): response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename=test.pdf' map_surface = cairo.PDFSurface(response, 1200, 700) m

我正在使用mapnik以PDF格式渲染地图,遇到了一个混乱的问题

def writeFile(m, mapId):
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename=test.pdf'

    map_surface = cairo.PDFSurface(response, 1200, 700)
    map_ctx = cairo.Context(map_surface)
    mapnik.render(m, map_ctx)
    legend = createLegend(map_ctx, mapId)

    map_surface.finish()
    return response
我们用的是Django。上述功能在我的合作开发人员的计算机上运行良好,但在我的计算机上崩溃。问题在于
mapnik.render()
函数。我最终出现以下错误:

python: /build/buildd/cairo-1.12.2/src/cairo.c:301: cairo_destroy: Assertion `((*&(&cr->ref_count)->ref_count) > 0)' failed.
Aborted
当我用
mapnik.render(m,map\u surface)
将其关闭时,它工作正常。我尝试过卸载然后重新安装适当的库(libcairo2-dev、pythoncoaro、libmapnik、mapnik-utils),但没有任何效果

任何帮助都将不胜感激

编辑:

无意中解决了这个问题。已安装tilemill,它与mapnik捆绑在一起

sudo add-apt-repository ppa:developmentseed/mapbox
sudo apt-get update
sudo apt-get install tilemill libmapnik nodejs

Mapnik版本现在是
2.2.0-pre

您的合作开发者使用哪一个开罗版本?你有一个1.12.2版本,很明显你遇到了一个cairo bug,这个bug从那时起就被修复了。他使用的是1.12.2-1ubuntu2.2,和我一样。我升级到了1.12.14-0ubuntu1~quantal1,但是我仍然有同样的问题。2年后,这个bug仍然存在。有什么想法吗?mapnik并不是为我提供PDF或SVG,但那是另一回事。