本文介绍了dlopen()无法加载库:cairo / cairo-2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的观点:
from django.conf import settings
from django.http import HttpResponse
from django.template.loader import render_to_string
import weasyprint
@staff_member_required
def admin_order_pdf(request, order_id):
order = get_object_or_404(Order, id=order_id)
html = render_to_string('orders/order/pdf.html', {'order': order})
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)它给我一个错误。
when i want to import (import weasyprint) it gives me a error.
ERROR:
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/orders/order/
Django Version: 1.8.6
Exception Type: OSError
Exception Value:
dlopen() failed to load a library: cairo / cairo-2
我已经安装了weasyprint和cairocffi。我正在使用osx EI CAPITAN。
I already installed weasyprint and cairocffi. I'm using osx EI CAPITAN.
推荐答案
这是通过在Ubuntu上安装以下依赖项解决的:
This was solved for me by installing the following dependencies on Ubuntu:
sudo apt-get install libpango1.0-0
sudo apt-get install libcairo2
sudo apt-get install libpq-dev
查看链接中的依赖项:
http://weasyprint.readthedocs.io/en/latest/install.html
http://weasyprint.readthedocs.io/en/latest/install.html
这篇关于dlopen()无法加载库:cairo / cairo-2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!