Error Installing WeasyPrint
valeriuv
PROOP

a year 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 _gcd_import

Feb 03 19:03:06

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

Feb 03 19:03:06

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

Feb 03 19:03:06

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

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 _call_with_frames_removed

Feb 03 19:03:06

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

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 _gcd_import

Feb 03 19:03:06

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

Feb 03 19:03:06

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

Feb 03 19:03:06

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

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 _call_with_frames_removed

Feb 03 19:03:06

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

Feb 03 19:03:06

from . import views

Feb 03 19:03:06

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

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

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

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

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

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 = _make_ffi_library(self, name, flags)

Feb 03 19:03:06

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

Feb 03 19:03:06

backendlib = _load_backend_lib(backend, libname, flags)

Feb 03 19:03:06

File "/opt/venv/lib/python3.10/site-packages/cffi/api.py", line 827, in _load_backend_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

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 • over 1 year ago


valeriuv
PROOP

a year 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 • over 1 year ago


Status changed to Solved brody • over 1 year ago


angelo-railway

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"

shivamgarg001
FREE

a year ago

this is not working, i tried


Status changed to Awaiting Railway Response Railway • about 1 year ago


cpeguerob
HOBBY

a year 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.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...