Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't load pango #5

Open
ashleyoldershaw opened this issue May 20, 2021 · 0 comments
Open

Can't load pango #5

ashleyoldershaw opened this issue May 20, 2021 · 0 comments

Comments

@ashleyoldershaw
Copy link

Hi all,

I'm working on getting a Weasyprint lambda set up and followed the instructions shown to try and get it all running.

If anyone reading this has managed to get it working I'd love to see how you did it :)

I also used the commands from pull requests #2 and #4 and have got the layer deployed on Lambda. When I run it I get the error below. I'm running on python 3.7.

I'm deploying this via GitHub actions if that makes any difference.

{
  "errorMessage": "cannot load library 'pango-1.0': libthai.so.0: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'pango-1.0'",
  "errorType": "OSError",
  "stackTrace": [
    "  File \"/var/lang/lib/python3.7/imp.py\", line 234, in load_module\n    return load_source(name, filename, file)\n",
    "  File \"/var/lang/lib/python3.7/imp.py\", line 171, in load_source\n    module = _load(spec)\n",
    "  File \"<frozen importlib._bootstrap>\", line 696, in _load\n",
    "  File \"<frozen importlib._bootstrap>\", line 677, in _load_unlocked\n",
    "  File \"<frozen importlib._bootstrap_external>\", line 728, in exec_module\n",
    "  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n",
    "  File \"/var/task/lambda_handler.py\", line 1, in <module>\n    from weasyprint import HTML\n",
    "  File \"/var/task/weasyprint/__init__.py\", line 469, in <module>\n    from .css import preprocess_stylesheet  # noqa isort:skip\n",
    "  File \"/var/task/weasyprint/css/__init__.py\", line 27, in <module>\n    from . import computed_values, counters, media_queries\n",
    "  File \"/var/task/weasyprint/css/computed_values.py\", line 15, in <module>\n    from .. import text\n",
    "  File \"/var/task/weasyprint/text.py\", line 261, in <module>\n    'libpango-1.0.dylib')\n",
    "  File \"/var/task/weasyprint/text.py\", line 255, in dlopen\n    return ffi.dlopen(names[0])  # pragma: no cover\n",
    "  File \"/var/task/cffi/api.py\", line 150, in dlopen\n    lib, function_cache = _make_ffi_library(self, name, flags)\n",
    "  File \"/var/task/cffi/api.py\", line 832, in _make_ffi_library\n    backendlib = _load_backend_lib(backend, libname, flags)\n",
    "  File \"/var/task/cffi/api.py\", line 827, in _load_backend_lib\n    raise OSError(msg)\n"
  ]
}

My lambda handler is the simplest one I could find:

from weasyprint import HTML


def lambda_handler(event, context):
    html = HTML(string='<html><body><h1>Hello, world</h1></body></html>')
    html.write_pdf('/tmp/hello_world.pdf')

My requirements.txt file is also as simple as possible:

weasyprint
jinja2

Here are the logs I'm getting out:

START RequestId: a1d4bb8d-a913-4058-9ae7-f1982705865f Version: $LATEST
[ERROR] OSError: cannot load library 'pango-1.0': libthai.so.0: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'pango-1.0'
Traceback (most recent call last):
  File "/var/lang/lib/python3.7/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/var/lang/lib/python3.7/imp.py", line 171, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/task/lambda_handler.py", line 1, in <module>
    from weasyprint import HTML
  File "/var/task/weasyprint/__init__.py", line 469, in <module>
    from .css import preprocess_stylesheet  # noqa isort:skip
  File "/var/task/weasyprint/css/__init__.py", line 27, in <module>
    from . import computed_values, counters, media_queries
  File "/var/task/weasyprint/css/computed_values.py", line 15, in <module>
    from .. import text
  File "/var/task/weasyprint/text.py", line 261, in <module>
    'libpango-1.0.dylib')
  File "/var/task/weasyprint/text.py", line 255, in dlopen
    return ffi.dlopen(names[0])  # pragma: no cover
  File "/var/task/cffi/api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/var/task/cffi/api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "/var/task/cffi/api.py", line 827, in _load_backend_lib
    raise OSError(msg)
END RequestId: a1d4bb8d-a913-4058-9ae7-f1982705865f
REPORT RequestId: a1d4bb8d-a913-4058-9ae7-f1982705865f	Duration: 5031.58 ms	Billed Duration: 5032 ms	Memory Size: 128 MB	Max Memory Used: 28 MB	
Unknown application error occurred
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant