import pyvips throws exception for python 2.7 and 3.6 in AWS lambda (ZLIB_1.2.9 not found while loading libvips.so.42)
See original GitHub issueI’m writing a AWS Lambda function using pyvips python package. But it throws exception when import pyvips
is executed. The error is as follows. I’ve zipped cffi, pycparser, pyvips and a lib directory which contains all the shared libraries of libvips for lambda build package. I’ve also set the environment variable LD_LIBRARY_PATH=./lib:LD_LIBRARY_PATH
.The lambda.zip that I’m uploading to the AWS lambda can be found here.
cannot load library 'libvips.so.42': /lib64/libz.so.1: version `ZLIB_1.2.9' not found (required by ./lib/libpng16.so.16). Additionally, ctypes.util.find_library() did not manage to locate a library called 'libvips.so.42': OSError
Traceback (most recent call last):
File "/var/task/lambda.py", line 5, in lambda_handler
import pyvips
File "/var/task/pyvips/__init__.py", line 54, in <module>
vips_lib = ffi.dlopen(_vips_libname)
File "/var/task/cffi/api.py", line 141, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "/var/task/cffi/api.py", line 802, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
File "/var/task/cffi/api.py", line 797, in _load_backend_lib
raise OSError(msg)
OSError: cannot load library 'libvips.so.42': /lib64/libz.so.1: version `ZLIB_1.2.9' not found (required by ./lib/libpng16.so.16). Additionally, ctypes.util.find_library() did not manage to locate a library called 'libvips.so.42'
END RequestId: af867599-5876-11e8-a3ca-ffec3ebba19d
REPORT RequestId: af867599-5876-11e8-a3ca-ffec3ebba19d Duration: 459.45 ms Billed Duration: 500 ms Memory Size: 128 MB Max Memory Used: 21 MB
This may not be a problem of libvips or pyvips but some setting in AWS Lambda function that I don’t know. Created an issue with AWS as well.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Resolve "Unable to import module" errors from Python ...
I receive an "Unable to import module" error when I try to run my AWS Lambda code in Python. How do I resolve...
Read more >Unable to import libraries in AWS Lambda python
The answer you linked uses a Lambda layer, however you deployed your function using a deployment package together with its dependencies.
Read more >How do I resolve the "Unable to import module" error I receive ...
How do I resolve the "Unable to import module" error I receive when I run Lambda code in Python ?
Read more >Resolving import issues when deploying Python code to ...
AWS Lambda is Amazon's “serverless” compute platform that basically lets you run code without thinking (too much) of servers.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think docker would be fine since it manages all its libraries. In my case I’m running a Lambda function without docker. And the problem is that even though I provide all the necessary libraries in lib directory and set the environment path
LD_LIBRARY_PATH=./lib
. It seems Lambda in unable to load all the libraries from thislib
directory. I’ve found a work around which is running another process with my correct configuration set for the library path and load pyvips in that process only. It seems to work. It is a work around and the down side is that you need to create another process and manage it. So it comes with all the regular downside of it. But for now it is working fine. I mainly posted it here for the community and the AWS team to look into. This is not a VIPS problem and I’ll update here if I find anything better.Hey @baxhul could you maybe report how you solved the issue in more detail? I am facing the same right now.