Having trouble running lambda functions for slack bot/app with Python 3.8

Interesting… Anyone had issues running lambda functions (python 3.8) for slack bot/app? My code works fine locally. I only had to pip install slackclient and in my code I can use import slack and it works fine. But when trying that with aws lambda, it fails with "errorMessage": "Unable to import module 'handler': No module named 'slack'". I already tried to include in my requirements.txt the following: slackclient==2.9.4 (fails), slack-sdk==3.27.1 (fails) and slack which also fails… they all return with that same error.

You could try debugging by downloading the lambda that was uploaded and checking for the existance of this package. It may not be getting packaged correctly

considering all are failing, it seems like no external dependencies are being packaged

what are you using to deploy the lambda?

let me try downloading my lambda function as you said to see if it was packaged properly

Ah you may not being using the plugin to package dependencies

https://www.serverless.com/examples/aws-python

serverless plugin install -n serverless-python-requirements

and it’s in my serverless.yaml


frameworkVersion: '3'

provider:
  name: aws
  runtime: python3.8

functions:
  hello:
    handler: handler.hello
    events:
      - httpApi:
          path: /hello
          method: post

plugins:
  - serverless-python-requirements

custom:
  pythonRequirements:
    dockerizePip: true
    layer:
      name: python-slack```

Your dependency is within a layer? is the layer attached to the function?

sorry, I’m trying serverless for the first time… so also still getting used to it

let. mesee how to check that…

BUT… now that you said that…

checking on aws lambda… I see Layers (0)

I think that layer is probably going to overcomplicate this. Why not just install slack dependency within your main app?

right, let me try that

would it be just a matter of commenting out the lines layer and name, right!? based on what I see in the docs here: https://www.serverless.com/plugins/serverless-python-requirements

just keeping the custom block with the pythonrequirements

let me give it a try… and thanks by the way