AWS Lambda with Zappa fails on “Unable to import module 'handler': No module named builtins”

0 votes

I've deployed my application to AWS Lambda with Zappa. The deployment went fine without any issues. But when I try to reach the app via AWS API Gateway I get a 500 response.

The logs says

Unable to import module 'handler': No module named builtins

The environment runs on Python 2.7. I've added future to the Pipfile but it still won't work.

When I check the code in Lambda I can see the following code

from __future__ import unicode_literals

import base64
import boto3
import collections
import datetime
import importlib
import inspect
import json
import logging
import os
import sys
import traceback
import zipfile

from builtins import str

I can't find what can be wrong. Does anyone have a clue?

Sep 18, 2018 in AWS by bug_seeker
• 15,480 points

1 answer to this question.

0 votes

I solved the problem. I'm using pipenv to install my packages, but for some reason the packages wasn't installed inside the virtual environment, which made Zappa to not include them to AWS Lambda. I had to install them manually in PyCharm by going through Settings > Project > Project Interpreter and add the packages there. Thanks for your help.

answered Sep 18, 2018 by Priyaj
• 57,640 points

Related Questions In AWS

+1 vote
1 answer

'No module named 'requests'' on the AWS Python Lambda function?

Hi@akhtar, According to my knowledge requests is not ...READ MORE

answered Apr 15 in AWS by MD
• 53,620 points
0 votes
1 answer

Unable to import module 'lambda_function': No module named lambda_function

Hi@akhtar, This error appears when you haven’t named ...READ MORE

answered Apr 28 in AWS by MD
• 53,620 points
0 votes
1 answer

how to import numpy and pandas inside aws lambda function?

The problem is that your local numpy ...READ MORE

answered Sep 14, 2018 in AWS by Priyaj
• 57,640 points
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
+3 votes
3 answers

Unable to login to parse dashboard on AWS

During the first time boot, the application ...READ MORE

answered Apr 30, 2018 in AWS by Cloud gunner
• 4,650 points
+1 vote
1 answer