How to Handle your Python packaging in Lambda with Serverless plugins
Python is my go-to language, but handling Python packages in Lambda can be tricky. So in this blog i will tell you how you can Handel your python package in Lambda with serverless plugins.
Here few steps using you can handle your python package in Lambda function
Step 1- You need to install
npm install serverless-python-requirements
Step 2- Then add the following to your
Step 3- Make sure you have your python virtual environment active in CLI
workon <env name>
Step 4- Install any dependencies with pip — note that in CLI you can tell if venv is active by the
venv to the left of the terminal text
(venv) $ pip install <NAME>
(venv) $ pip freeze > requirements.txt
Step 5- Now, deploy your function
What will happen is that
serverless-python-requirements will build you python packages in docker using a lambda environment, and then zip them up ready to be uploaded with the rest of your code.