Lambda using Python and GDAL

I am trying to create a lambda function that will use GDAL libraries. I am working within a virtualenv on my Ubuntu 16.04 machine using Python 3.5. GDAL works fine in the virtual environment until i try to deploy it to lambda. I am following this tutorial, replacing GDAL for NumPy. When i run serverless deploy, I get the following error:

Serverless: Installing requirements of requirements.txt in .serverless…
Serverless: Docker Image: lambci/lambda:build-python3.6
Error --------------------------------------------------
The directory ‘/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
The directory ‘/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-install-yo9exd91/pygdal/
For debugging logs, run again after setting the “SLS_DEBUG=*” environment variable.

I already updated setuptools, which didn’t change the error message. I also checked the owner and permissions for the /.cache/pip directory which match my current user. Already tried using this method as well.

If anyone has created lambda functions from serverless using GDAL, any help would be appreciated.

1 Like

Were you able to find any solution?