python - 操作系统错误 : cannot load library 'gobject-2.0' : error 0x7e

标签 python django windows lib weasyprint

我安装了软件包 weasyprint 按照说明Installing weasyprint (Django 项目)。
我的系统:win 10。我已经安装了 gtk3 它存在于我的 中路径
PAYH gtk3

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: cannot load library 'gobject-2.0': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'gobject-2.0'

最佳答案

我绝望了,决定安装库 gtk2 C:\Program Files (x86)\GTK2\lib\并指定 PATH 列表中的第一个。它有效......但我的操作系统 - 赢得 10 x64。为什么库 GTK3 拒绝工作,我不知道。

关于python - 操作系统错误 : cannot load library 'gobject-2.0' : error 0x7e,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63449770/

相关文章:

Django - 是否可以直接在设置文件中从云服务加载 secret /密码/动态值

python - Django 将 isoformat 字符串日期时间转换为元组并出现错误

java - Java 中循环技巧的 Helloworld 示例

eclipse - Eclipse 控制台 View 中的 "Terminate"使 node.exe 保持运行

django - 删除了多少行?

c - 在 Windows 上使用哪个单元测试框架进行 C 开发?

Python:从内部类访问外部私有(private)函数

python - Pandas 替换为默认值

python - 有一个不以 return 语句结尾的函数是 pythonic 吗

python - 替换 Numpy 数组中的多个值