python - OSError:无法加载库“gobject-2.0”:错误 0x7e
问题描述
我根据安装 weasyprint(Django 项目)的说明安装了包weasyprint 。我的系统:win 10。我已经安装了gtk3,它存在于我的PATH中
import weasyprint
...
@staff_member_required
def order_admin_pdf(request, order_id):
# Получаем заказ по ID:
order = get_object_or_404(Order, id=order_id)
# Передаем объект в функцию render_to через генерацию шаблона pdf.html HTML в виде строки:
html = render_to_string('shop/orders/order_admin_pdf.html',
{'order': order})
# Создаем объект овтета с типом содержимого application/pdf и заголовком Content-Disposition:
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'filename=order_{}.pdf"'.format(order.id)
# Вызов метода weasyprint для получения PDF документа:
weasyprint.HTML(string=html).write_pdf(response,
stylesheets=[weasyprint.CSS(
settings.STATIC_ROOT + 'css/pdf.css')])
return response
OSError:无法加载库“gobject-2.0”:错误 0x7e。此外,ctypes.util.find_library() 无法找到名为“gobject-2.0”的库
解决方案
我绝望了,决定安装库 gtk2C:\Program Files (x86)\GTK2\lib\
并在 PATH 列表中指定第一个。它工作......但我的操作系统 - 赢得 10 x64。为什么库 GTK3 拒绝工作,我不知道。
推荐阅读
- apache-kafka - 找不到 kafka StoreBuilder 类
- javascript - jqGrid 字符串自定义格式,如日期格式
- node.js - 如何将路由控制从 Node 服务器传递到客户端?
- python-3.x - Python 3 优先重新排列元组
- python - 如何将参数从 PyQt5 QSpinBox 传输到 Matplotlib?
- python-3.x - shutil.move() 显示错误,即使路径正确
- c# - Textbox_Enter 事件不执行任何操作
- asp.net - 具有所有人权限的 .NET Web 应用程序拒绝访问网络文件夹
- python - CV2 中的estimateTransformation 与文档不同
- python - 我可以修改 Tensorflow 自定义操作中的输入吗?