hi! I've been having a "RunTime.ImportModuleError:...
# help
r
hi! I've been having a "RunTime.ImportModuleError: Unable to import module 'lambda': No module named 'src' " error when I deploy my stack which contains a lambda function written in python that is triggered by a certain event. Has anyone had this problem? My folder structure is scheduling-algorithm | |-- lib |-- |--index.js |--|-- MyStack.js |-- src |--|-- init.py |--|-- lambda.py |-- |-- init.py |-- sst.json |-- package.json
f
Hey @Ricardo Arancibia, are you getting this on
sst deploy
or
sst start
?
r
I can build and deploy my stack, this error happens when I test the lambda in the aws console
this error didn't happen when I created an API with
Copy code
const api = new sst.Api(this, "Api", {
      defaultFunctionProps: {
        srcPath: "src",
      },
      routes: {
        "GET /": "lambda.scheduling",
      }
my current lambda configuration is
Copy code
const multicenter = new sst.Function(this, "scheduling", {
      srcPath: "src",
      handler: "lambda.scheduling",
      permissions: permissions,
      environment: environmentLambda,
      runtime: "python3.7"
    })
f
Just to clarify: • are the Api routes ie.
lambda.handler
also in Python? Where are you specifying the runtime for that? • was your flow: run
sst deploy
> invoke
scheduling
from AWS console > got the error?
r
I'm currently not implementing an API, this message https://serverless-stack.slack.com/archives/C01JG3B20RY/p1626893460333200?thread_ts=1626893104.332600&cid=C01JG3B20RY was about something that I was testing a time ago. Our idea now is to define a lambda in my stack that can be triggered by an event from the event bus
this is my current lambda configuration https://serverless-stack.slack.com/archives/C01JG3B20RY/p1626893512333400?thread_ts=1626893104.332600&cid=C01JG3B20RY
lambda.scheduling
is in python • and yes, that was my workflow. Before the
sst deploy
I made a
sst build
f
Got it. As for the flow, is it 1 or 2? 1. run 
sst deploy
 > invoke 
scheduling
 from AWS console > got the error; or 2. run 
sst start
 > invoke 
scheduling
 from AWS console > got the error
r
the option 1
f
I see. Can I see what your lambda.py looks like? (Feel free to DM me if that works better). And I can give it a try.
It mocks ur repo structure:
Copy code
/
  sst.json
  src/
    dir_a/
      file_a.py
    dir_b/
      file_b.py
    lambda.py
dir_a
is like your
service
dir_b
is like your
scheduling_temis
And
lambda.py
imports something from
dir_a/file_a.py
, and
file_a.py
imports something from
dir_b/file_b.py
You can try deploying this and see if it works for you.
r
thanks Frank! It did work when I used the way you import the function in sibling packages in the cloud
but unfortunately it stopped working locally with those imports
I'll try to find a way to fix that, but thanks! I was really stuck on this
f
What SST version are you using? We fixed a Python import related issue recently.
r
I'm using version 0.31.0
f
You can try upgrading to the latest v0.35.0 that is
r
I'll give it a try. Thanks Frank!