I am facing an issue with AWS lambda function. I am unable to import pygit2 library into my function. I tried it on 4 different runtime environments and each gives a different error, which makes me think that there is something wrong within the library rather than my code. These are the errors I get: github_pull_source is the name of my function.
Python 2.7 - Unable to import module 'github_pull_source': No module named _pygit2
Python 3.6 - Unable to import module 'github_pull_source': /var/task/_cffi_backend.so: undefined symbol: _Py_ZeroStruct
Python 3.7 - Unable to import module 'github_pull_source': No module named 'pygit2._pygit2'
Python 3.8 - Unable to import module 'github_pull_source': No module named 'pygit2._pygit2'
I import the library like so:
from pygit2 import Keypair, discover_repository, Repository, clone_repository, RemoteCallbacks
Structure of the deployment package
deployment_package.zip
- source_code.py
- __init__.py
- pygit2
- libgit2-f9f42b17.so.1.0.0
- libgit2.tar.gz
- libgit2.so.26
- _pygit2.so
- and some other libraries like requests etc
Have anyone experienced anything similar?
Thanks
I have now managed to solve the problem by creating a lambda layer. The problem seems to be with the python packages that are in the lambda container by default.
See details in this issue I raised here.
Hopefully this will help others too.