0

I am trying to import the git library needed to clone the repo from gitlab. A lot of research suggested that the best way would be to add a layer to the lambda function. So, I created a lambda layer with the below commands:

mkdir lambda_layers
cd lambda_layers
mkdir python
cd python
pip install gitpython -t ./
cd .. && zip -r python_modules.zip .  

When I added the zip file to the lambda function and tried running the function with nothing but just an import statement i.e import git and print("hello world") it gave me the below error:

[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': Failed to initialize: Bad git executable.
The git executable must be specified in one of the following ways:
    - be included in your $PATH
    - be set via $GIT_PYTHON_GIT_EXECUTABLE
    - explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|none|n|0: for no warning or exception
    - warn|w|warning|1: for a printed warning
    - error|e|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet

So what am I missing here? My zip structure is the same as the official documentation still the error.

RushHour
  • 494
  • 6
  • 25
  • This can be caused by a few things. Try checking some of the answers in this thread: https://stackoverflow.com/questions/35340921/aws-error-from-python-no-module-named-lambda-function – Trygvi Laksafoss Jun 01 '23 at 07:15
  • None of the solutions helped me. I am doing the zipping thing the right way. I tried multiple approaches but no luck. – RushHour Jun 01 '23 at 10:43
  • @TrygviLaksafoss Well, I confirmed that this way of creating a layer is correct since I tried out other libraries but it's just that it doesn't work for `gitpython` library – RushHour Jun 02 '23 at 09:26

0 Answers0