'Problem with weasyprint, when running pyhton file
Hi I am trying to convert html document to pdf using weasyprint, but when ever I run the script an error appears weasyprint is already installed.
Following is the script
from weasyprint import HTML, CSS
css = CSS(string='''
@page {size: A4; margin: 1cm;}
th, td {border: 1px solid black;}
''')
HTML('html_report_jinja.html').write_pdf('weasyprint_pdf_report.pdf', stylesheets=[css])
Error:
Traceback (most recent call last):
File "D:\HP Zbook\F\Projects\Desktop App\Printing Test\export_to_htm_template to pdf.py", line 1, in <module>
from weasyprint import HTML, CSS
File "D:\HP Zbook\F\Projects\Desktop App\Printing Test\venv\lib\site-packages\weasyprint\__init__.py", line 325, in <module>
from .css import preprocess_stylesheet # noqa isort:skip
File "D:\HP Zbook\F\Projects\Desktop App\Printing Test\venv\lib\site-packages\weasyprint\css\__init__.py", line 27, in <module>
from . import computed_values, counters, media_queries
File "D:\HP Zbook\F\Projects\Desktop App\Printing Test\venv\lib\site-packages\weasyprint\css\computed_values.py", line 16, in <module>
from ..text.ffi import ffi, pango, units_to_double
File "D:\HP Zbook\F\Projects\Desktop App\Printing Test\venv\lib\site-packages\weasyprint\text\ffi.py", line 404, in <module>
gobject = _dlopen(
File "D:\HP Zbook\F\Projects\Desktop App\Printing Test\venv\lib\site-packages\weasyprint\text\ffi.py", line 391, in _dlopen
return ffi.dlopen(names[0]) # pragma: no cover
File "D:\HP Zbook\F\Projects\Desktop App\Printing Test\venv\lib\site-packages\cffi\api.py", line 150, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "D:\HP Zbook\F\Projects\Desktop App\Printing Test\venv\lib\site-packages\cffi\api.py", line 832, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
File "D:\HP Zbook\F\Projects\Desktop App\Printing Test\venv\lib\site-packages\cffi\api.py", line 827, in _load_backend_lib
raise OSError(msg)
OSError: cannot load library 'gobject-2.0-0': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'gobject-2.0-0'
Thanks in advance
Solution 1:[1]
This sounds like a GTK issue. You can refer to this Issue thread for some possible solutions. Make sure that you have GTK3 cleanly installed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | tpa |