Giter Site home page Giter Site logo

awslambda_packages's Introduction

AWSLambda_Packages

Under the folder Compatible Packages, you can just download these packages that are already compatible to AWS Lambda runtime.

A repository explaining how to make Python Libraries into AWS Lambda compatible packages as a Layer.

Using Linux Environment

If you are using LinuxOS, this YouTube tutorial would satify your needs.
AWS lambda with OpenCV via Layers, video by Srce Cde - https://youtu.be/FQBT8vVRkAg

In short,

  1. Using Linux Terminal, pip3 install the Python libraries you want into a specific folder of directory build/python/lib/python3.8/site-packages
    For more information on the directory to use, take a look at: AWS Developer Guide - Including library dependencies in a layer - https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path
  2. then zip up the python folder at build/python. In your /build directory, you should have the /python/lib/python3.8/site-packages folder and the zipped folder (python.zip)
  3. Create a S3 bucket (this bucket needs to be in the same region as your AWS Lambda function)
  4. Upload the zip file.
  5. Go to AWS Lambda, create a new layer, upload file from S3.
  6. Use this layer in your AWS Lambda function.
  7. Now, you can import that library in your function's code!

Using Windows Environment

If you are using WindowsOS, following the steps for LinuxOS will not work. This is because, AWS Lambda runs in the amazonlinux OS. And the package you created by following the LinuxOS is configurated/build for your local WindowsOS environment.

There are multiple ways to go about this:

  1. Docker and EC2 Compiling the libraries in an instance type of amazonlinux OS environment
  2. Using pypi and wheel
    This is by far the easiest.
    AWS Support - How do I add Python packages with compiled binaries to my deployment package and make the package compatible with Lambda? - https://aws.amazon.com/premiumsupport/knowledge-center/lambda-python-package-compatible/

    Rephrasing:
    1. At pypi.org. https://pypi.org/ , search the library that you want and navigate to the Download Files page
      eg, https://pypi.org/project/numpy/#files
    2. Download appropriate .whl file
      eg,
      For Python 3.8, download numpy-1.19.1-cp38-cp38-manylinux1_x86_64.whl
      For Python 3.7, download numpy-1.19.1-cp37-cp37m-manylinux1_x86_64.whl
    3. Check if you have wheel library in your environment.
      • Using command prompt, check if you have wheel installed
      pip3 show wheel
      
      • To install wheel, type
      pip3 install wheel
      
    4. Uncompress wheel file
    wheel unpack <dir-to-wheel_file>
    
    1. Move the relevant folders into a directory build\python\lib\python3.8\site-packages
      eg, in the case for (opencv) cv2, dlib, imutils, numpy, your build\python\lib\python3.8\site-packages should look like this

    2. Zip up the python folder at build\python.
      In your \build directory, you should have the build\python\lib\python3.8\site-packages folder and the zipped folder (python.zip)

    3. Create a S3 bucket (this bucket needs to be in the same region as your AWS Lambda function)

    4. Upload the zip file.

    5. Go to AWS Lambda, create a new layer, upload file from S3.

    6. Use this layer in your AWS Lambda function.

    7. Now, you can import that library in your function's code!

awslambda_packages's People

Contributors

joyobo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.