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,310 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
• 56,160 points

Related Questions In AWS

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
• 56,160 points
0 votes
1 answer

Unable to start express server on AWS instance

It's not your code — you can't connect ...READ MORE

answered Oct 1, 2018 in AWS by Priyaj
• 56,160 points
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
+1 vote
3 answers

Unable to login to parse dashboard on AWS

I had the same issue, which I ...READ MORE

answered Aug 28, 2018 in AWS by eatcodesleeprepeat
• 4,670 points
0 votes
1 answer