# ModuleNotFoundError when invoking local but URL works fine

**URL:** <https://forum.serverless.com/t/modulenotfounderror-when-invoking-local-but-url-works-fine/6151>\
**Category:** Serverless Framework\
**Tags:** aws, lambda\
**Created:** [October 16, 2018, 9:47pm UTC](https://forum.serverless.com/t/modulenotfounderror-when-invoking-local-but-url-works-fine/6151 "2018-10-16T21:47:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hackman](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/hackman/32/1727_2.png) [@hackman](https://forum.serverless.com/u/hackman)\
**Post date:** [October 16, 2018, 9:47pm UTC](https://forum.serverless.com/t/modulenotfounderror-when-invoking-local-but-url-works-fine/6151/1 "2018-10-16T21:47:27Z")

</div>

I am getting a ModuleNotFoundError when trying to invoke a Python Lambda function locally. However, if I browse to the URL it works perfectly fine. I have reduced the code down to almost nothing and its still throwing the error. Its basically just the default code from sls create with a folder to import a module with a **init**.py in the folder. The class has 1 method. Using Serverless Framework 1.32.0

As you can see its about as basic as you can get.  
root folder:  
drwxr-xr-x 4 mvivanco staff 136B Oct 16 15:31 dal/  
-rw-r–r-- 1 mvivanco staff 222B Oct 16 17:17 handler.py  
-rw-r–r-- 1 mvivanco staff 2.9K Oct 16 17:26 serverless.yml

dal folder contents:  
-rw-r–r-- 1 mvivanco staff 140B Oct 16 15:31 TeacherDAL.py  
-rwxr-xr-x 1 mvivanco staff 0B Oct 16 15:28 **init**.py

**init**.py is empty  
contents of dal/TeacherDAL.py  
class TeacherDAL(object):  
@staticmethod  
def getTeacher():  
return {“Name”:“John Doe”}

contents of handler.py  
import json  
from dal.TeacherDAL import TeacherDAL

def hello(event, context):  
result = TeacherDAL.getTeacher()  
response = {  
“statusCode”: 200,  
“body”: json.dumps(result)  
}  
return response

contents of serverless.yml  
service: temp6  
provider:  
name: aws  
runtime: python3.6

functions:  
hello:  
handler: handler.hello  
events:  
- http:  
path: /teacher/get  
method: get  
cors: true  
integration: lambda-proxy

The error being thrown is:  
Traceback (most recent call last):  
File “/usr/local/lib/node\_modules/serverless/lib/plugins/aws/invokeLocal/invoke.py”, line 60, in \<module\>  
module = import\_module(args.handler\_path.replace(’/’, ‘.’))  
File “/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/ **init**.py”, line 126, in import\_module  
return \_bootstrap.\_gcd\_import(name[level:], package, level)  
File “\<frozen importlib.\_bootstrap\>”, line 994, in \_gcd\_import  
File “\<frozen importlib.\_bootstrap\>”, line 971, in \_find\_and\_load  
File “\<frozen importlib.\_bootstrap\>”, line 955, in \_find\_and\_load\_unlocked  
File “\<frozen importlib.\_bootstrap\>”, line 665, in \_load\_unlocked  
File “\<frozen importlib.\_bootstrap\_external\>”, line 678, in exec\_module  
File “\<frozen importlib.\_bootstrap\>”, line 219, in \_call\_with\_frames\_removed  
File “./handler.py”, line 2, in \<module\>  
from dal.TeacherDAL import TeacherDAL  
ModuleNotFoundError: No module named ‘dal.TeacherDAL’
