4 months ago
Hi!
I'm trying to install weasyprint for pdf generation and get this OS error:
Traceback (most recent call last):
for pattern in self.url_patterns:
File "/opt/venv/lib/python3.10/site-packages/django/utils/functional.py", line 57, in get
res = instance.__dict__[self.name] = self.func(instance)
File "/opt/venv/lib/python3.10/site-packages/django/urls/resolvers.py", line 715, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/opt/venv/lib/python3.10/site-packages/django/utils/functional.py", line 57, in get
res = instance.__dict__[self.name] = self.func(instance)
File "/opt/venv/lib/python3.10/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
return import_module(self.urlconf_name)
File "/root/.nix-profile/lib/python3.10/importlib/__init__.py", line 126, in import_module
return bootstrap.gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in gcdimport
File "<frozen importlib._bootstrap>", line 1027, in findand_load
File "<frozen importlib._bootstrap>", line 1006, in findand_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in loadunlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in callwith_frames_removed
File "/app/fleetdata/urls.py", line 26, in <module>
path('dispatchers/', include('dispatchers.urls', namespace='dispatchers')),
File "/opt/venv/lib/python3.10/site-packages/django/urls/conf.py", line 38, in include
urlconf_module = import_module(urlconf_module)
File "/root/.nix-profile/lib/python3.10/importlib/__init__.py", line 126, in import_module
return bootstrap.gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in gcdimport
File "<frozen importlib._bootstrap>", line 1027, in findand_load
File "<frozen importlib._bootstrap>", line 1006, in findand_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in loadunlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in callwith_frames_removed
File "/app/dispatchers/urls.py", line 2, in <module>
from . import views
File "/app/dispatchers/views.py", line 1765, in <module>
from weasyprint import HTML
File "/opt/venv/lib/python3.10/site-packages/weasyprint/__init__.py", line 429, in <module>
from .css import preprocess_stylesheet # noqa: I001, E402
File "/opt/venv/lib/python3.10/site-packages/weasyprint/css/__init__.py", line 28, in <module>
from .computed_values import COMPUTER_FUNCTIONS
File "/opt/venv/lib/python3.10/site-packages/weasyprint/css/computed_values.py", line 9, in <module>
from ..text.ffi import FROM_UNITS, ffi, pango
File "/opt/venv/lib/python3.10/site-packages/weasyprint/text/ffi.py", line 463, in <module>
gobject = _dlopen(
File "/opt/venv/lib/python3.10/site-packages/weasyprint/text/ffi.py", line 451, in _dlopen
return ffi.dlopen(names[0], flags) # pragma: no cover
File "/opt/venv/lib/python3.10/site-packages/cffi/api.py", line 150, in dlopen
lib, function_cache = makeffi_library(self, name, flags)
File "/opt/venv/lib/python3.10/site-packages/cffi/api.py", line 832, in makeffi_library
backendlib = loadbackend_lib(backend, libname, flags)
File "/opt/venv/lib/python3.10/site-packages/cffi/api.py", line 827, in loadbackend_lib
raise OSError(msg)
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
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"
2 months ago
this is not working, i tried
Status changed to Awaiting Railway Response railway[bot] • about 2 months ago
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.