Managing Python Dependencies in Serverless

Prerequisites

In order to run the following commands, you need to have a Ubuntu (or any other Debian-based) work environment up and running!

STEPS

  1. Upgrade pip and virtaulenv
    Run the following commands:

    sudo -H pip3 install --upgrade pip
    sudo -H pip3 install virtualenv
    
    • Then we need to create a virtaulenv
    python3 -m venv your_venv
    
    • Now we have to activate it.
    source your_venv/bin/activate
    
    • Install all the dependencies specified in the requirements.txt file
    pip install -r requirements.txt
    
  2. Install the Serverless Python Requirements Plugin

    sls plugin install -n serverless-python-requirements
    

    This will automagically add the plugin to the serverless.yml file

    plugins:
       - serverless-python-requirements
    
    • To make the package of python dependencies, run
    sls package
    
    • Now deploy it to AWS
    sls deploy
    

    All okay? Boom!

Saimon

Software Development Engineer I

Published: July 17, 2023

UPD: July 20, 2023

Get In Touch

Map

The power of Technology

is now at your disposal

Address:

Plot # 272, Lane # 3 (Eastern Road)
DOHS Baridhara, Dhaka 1206

Phone:

+880 1730 3586 45

Email:

Our Experts are Ready to Help You

    captcha

    Contact Us Directly

    Address:

    Plot # 272,
    Lane # 3 (Eastern Road)
    DOHS Baridhara, Dhaka 1206

    Talk to Us

    +880 1730 3586 45