Python OSError:dlopen()未能加载库:cairo/cairo-2/cairo-gobject-2

Python OSError:dlopen()未能加载库:cairo/cairo-2/cairo-gobject-2,python,django,django-rest-framework,weasyprint,Python,Django,Django Rest Framework,Weasyprint,我的看法 @api_view(['GET']) @renderer_classes((JSONRenderer,TemplateHTMLRenderer,BrowsableAPIRenderer)) def admin_order_pdf(request, order_id): # def admin_order_pdf(request, order_id): order = get_object_or_404(Direct, id=order_id)

我的看法

@api_view(['GET'])
    @renderer_classes((JSONRenderer,TemplateHTMLRenderer,BrowsableAPIRenderer))
    def admin_order_pdf(request, order_id):
    # def admin_order_pdf(request, order_id):
        order = get_object_or_404(Direct, id=order_id)
        price=order.price
        discount=order.discount
        total=price-discount
        html = render_to_string('bill/bill.html',
        {'order': order,'total':total})
        response = HttpResponse(content_type='application/pdf')
        response['Content-Disposition'] = 'filename=\
        "order_{}.pdf"'.format(order.id)
        weasyprint.HTML(string=html).write_pdf(response,
        stylesheets=[weasyprint.CSS(
        settings.STATIC_ROOT + 'css/pdf.css')])
        return response
当我尝试运行服务器或尝试运行weasyprint代码时 我被一个错误激怒了 作为

我也更新了我的环境变量

C:\Program Files\GTK3-Runtime Win64\bin

到这个位置

确保安装了用于pixman(libpixman1-devel)、png、pango和poppler(PDF生成)的Cygwin开发库。为此,运行Cygwin安装程序,查找pixman、poppler和libpng,并安装devel库

当我为Pango安装开发库时,我注意到它安装了Cairo和其他DEP的特殊“GTK”版本

一旦我安装了这些Cygwin库,一切都正常了,上面的错误消息消失了(我还从源代码处编译并安装了Pixman,这可能是修复的一部分,也可能不是修复的一部分)

C:\Program Files\GTK3-Runtime Win64\bin