question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot load libgobject-2.0.so when running on aws lambda

See original GitHub issue

Hey, I am currently trying to deploy libvips+pyvips as an aws lambda layer, but I am currently unable to successfully package the libraries as it seems. I am building vips in a docker container by invoking

RUN ./autogen.sh --prefix /opt/vips \
  && make V=0 \
  && make install

Afterwards, I install pyvips like this:

RUN python3 -m pip install \
   -t /opt/python \
   --python-version "3.9" \
   --only-binary=:all: \
   pyvips

Finally, I zip the content of /opt, and upload it as a layer.

When invoking a function relying on pyvips, I get the following error:

[ERROR] OSError: cannot load library 'libgobject-2.0.so.0': libgobject-2.0.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 'libgobject-2.0.so.0'
Traceback (most recent call last):
  File "/var/task/serverless_sdk/__init__.py", line 144, in wrapped_handler
    return user_handler(event, context)
  File "/var/task/s_trigger.py", line 25, in error_handler
    raise e
  File "/var/task/s_trigger.py", line 20, in <module>
    user_handler = serverless_sdk.get_user_handler('handler.trigger')
  File "/var/task/serverless_sdk/__init__.py", line 56, in get_user_handler
    user_module = import_module(user_module_name)
  File "/var/lang/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/var/task/handler.py", line 10, in <module>
    from conversion import convert_pdf_to_jpeg_on_s3
  File "/var/task/conversion.py", line 1, in <module>
    from pyvips import Image
  File "/opt/python/pyvips/__init__.py", line 53, in <module>
    gobject_lib = ffi.dlopen(_gobject_libname)
  File "/opt/python/cffi/api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/opt/python/cffi/api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "/opt/python/cffi/api.py", line 827, in _load_backend_lib
    raise OSError(msg)

I use python-serverless-requirements, but pyvips is not included in the requirements.txt file.

Do you know how I might be able to fix this problem?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AntonOellerercommented, Aug 24, 2022

You were correct, for some reason libgobject-2.0.so.0 exists in what I thought was the lambda image, but not in the lambda aws service, thank you!

0reactions
jcupittcommented, Aug 23, 2022

Well, libgobject-2.0.so.0 at first, but there could be others missing too, of course.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS Lambda Fails On Require · Issue #1885 · lovell/sharp
I am able to use Sharp locally on my Mac with a docker run command of docker run -v "$PWD":/var/task lambci/lambda:build-nodejs10.x node index2....
Read more >
Troubleshoot execution issues in Lambda - AWS Documentation
Errors can occur during function initialization, when your handler code processes the event, or when your function returns (or fails to return) a...
Read more >
"Unable to import module 'lambda_function': libasound.so.2 ...
Once installed you can package your python code and the .so files together and upload to AWS lambda. The folder structure for your...
Read more >
Wrong Elf Class: Elfclass32 When Using Linux - ADocLib
error while loading shared libraries: libstdc++.so.6: wrong ELF class: I just changed the softlink by issuing the following command in /usr/lib folder: rm...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found