Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import own module within aws lambda function

I am trying to import my own module but I am getting error:

Unable to import module 'lambda_function': attempted relative import with no known parent package

lambda_function.py

enter image description here

Own modulename.py

enter image description here

like image 755
Manish Pushpam Avatar asked Jun 10 '26 00:06

Manish Pushpam


1 Answers

You import it as if you were to import any other Python module. In other words don't do this:

from .name import *

but do this:

from name import show_name

For example:

enter image description here

The contents of name.py:

def my_name():
    print("Your name goes here.")

Don't forget to Deploy your function after making changes.

like image 83
baduker Avatar answered Jun 11 '26 13:06

baduker