Error Installing WeasyPrint

valeriuvPRO

4 months ago

Hi!

I'm trying to install weasyprint for pdf generation and get this OS error:

Traceback (most recent call last):

Feb 03 19:03:06

for pattern in self.url_patterns:

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/django/utils/functional.py", line 57, in get

Feb 03 19:03:06

res = instance.__dict__[self.name] = self.func(instance)

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/django/urls/resolvers.py", line 715, in url_patterns

Feb 03 19:03:06

patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/django/utils/functional.py", line 57, in get

Feb 03 19:03:06

res = instance.__dict__[self.name] = self.func(instance)

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/django/urls/resolvers.py", line 708, in urlconf_module

Feb 03 19:03:06

return import_module(self.urlconf_name)

Feb 03 19:03:06

File "/root/.nix-profile/lib/python3.10/importlib/__init__.py", line 126, in import_module

Feb 03 19:03:06

return bootstrap.gcd_import(name[level:], package, level)

Feb 03 19:03:06

File "<frozen importlib._bootstrap>", line 1050, in gcdimport

Feb 03 19:03:06

File "<frozen importlib._bootstrap>", line 1027, in findand_load

Feb 03 19:03:06

File "<frozen importlib._bootstrap>", line 1006, in findand_load_unlocked

Feb 03 19:03:06

File "<frozen importlib._bootstrap>", line 688, in loadunlocked

Feb 03 19:03:06

File "<frozen importlib._bootstrap_external>", line 883, in exec_module

Feb 03 19:03:06

File "<frozen importlib._bootstrap>", line 241, in callwith_frames_removed

Feb 03 19:03:06

File "/app/fleetdata/urls.py", line 26, in <module>

Feb 03 19:03:06

path('dispatchers/', include('dispatchers.urls', namespace='dispatchers')),

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/django/urls/conf.py", line 38, in include

Feb 03 19:03:06

urlconf_module = import_module(urlconf_module)

Feb 03 19:03:06

File "/root/.nix-profile/lib/python3.10/importlib/__init__.py", line 126, in import_module

Feb 03 19:03:06

return bootstrap.gcd_import(name[level:], package, level)

Feb 03 19:03:06

File "<frozen importlib._bootstrap>", line 1050, in gcdimport

Feb 03 19:03:06

File "<frozen importlib._bootstrap>", line 1027, in findand_load

Feb 03 19:03:06

File "<frozen importlib._bootstrap>", line 1006, in findand_load_unlocked

Feb 03 19:03:06

File "<frozen importlib._bootstrap>", line 688, in loadunlocked

Feb 03 19:03:06

File "<frozen importlib._bootstrap_external>", line 883, in exec_module

Feb 03 19:03:06

File "<frozen importlib._bootstrap>", line 241, in callwith_frames_removed

Feb 03 19:03:06

File "/app/dispatchers/urls.py", line 2, in <module>

Feb 03 19:03:06

from . import views

Feb 03 19:03:06

File "/app/dispatchers/views.py", line 1765, in <module>

Feb 03 19:03:06

from weasyprint import HTML

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/weasyprint/__init__.py", line 429, in <module>

Feb 03 19:03:06

from .css import preprocess_stylesheet # noqa: I001, E402

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/weasyprint/css/__init__.py", line 28, in <module>

Feb 03 19:03:06

from .computed_values import COMPUTER_FUNCTIONS

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/weasyprint/css/computed_values.py", line 9, in <module>

Feb 03 19:03:06

from ..text.ffi import FROM_UNITS, ffi, pango

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/weasyprint/text/ffi.py", line 463, in <module>

Feb 03 19:03:06

gobject = _dlopen(

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/weasyprint/text/ffi.py", line 451, in _dlopen

Feb 03 19:03:06

return ffi.dlopen(names[0], flags) # pragma: no cover

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/cffi/api.py", line 150, in dlopen

Feb 03 19:03:06

lib, function_cache = makeffi_library(self, name, flags)

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/cffi/api.py", line 832, in makeffi_library

Feb 03 19:03:06

backendlib = loadbackend_lib(backend, libname, flags)

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/cffi/api.py", line 827, in loadbackend_lib

Feb 03 19:03:06

raise OSError(msg)

Feb 03 19:03:06

OSError: cannot load library 'libgobject-2.0-0': libgobject-2.0-0: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called 'libgobject-2.0-0'

Thanks!

4 Replies

4 months ago

You can add the following env var to your service to enable the system dependencies to install weasyprint: NIXPACKS_PKGS="cairo pango gobject-introspection glib libffi pkg-config"


Status changed to Awaiting User Response railway[bot] 4 months ago


valeriuvPRO

4 months ago

Thank you! I finally managed to fix xml2pdf, which was freezing. But it's good to know in case I need to install system dependencies.


Status changed to Awaiting Railway Response railway[bot] 4 months ago


Status changed to Solved brody 4 months ago


angelo

You can add the following env var to your service to enable the system dependencies to install weasyprint: NIXPACKS_PKGS="cairo pango gobject-introspection glib libffi pkg-config"

shivamgarg001FREE

2 months ago

this is not working, i tried


Status changed to Awaiting Railway Response railway[bot] about 2 months ago


cpeguerobHOBBY

a month ago

Hello,
I have the same error:
OSError: cannot load library 'libgobject-2.0-0': libgobject-2.0-0: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called 'libgobject-2.0-0'

I tried with a nixpacks.toml file triying to force the install of dependencies:
nixPkgs = [

"python311",

"cairo",

"pango",

"gdk-pixbuf",

"glib",

"gobject-introspection",

"gtk3",

"gtk4",

"libxml2",

"libxslt",

"fontconfig",

"freetype",

"harfbuzz",

"pkg-config",

"shared-mime-info",

"libffi"

]

Still not worked.