Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unable to import module 'handler': No module named builtins #1262

Closed
shabbirmarzban opened this issue Nov 27, 2017 · 14 comments
Closed
Labels

Comments

@shabbirmarzban
Copy link

shabbirmarzban commented Nov 27, 2017

Context

I recently upgraded zappa to newest version (0.45.1). The module deploys well but request to gateway fail. Upon checking lambda tail I get following error
Unable to import module 'handler': No module named builtins
The zappa works fine if i downgrade to previous version but I want to upgrade to make use of async features(not implemented as yet. I have just upgraded the version of zappa).
I also cant afford to remove slim_handler=true as mentioned here: #1222
It would be great if anyone can tell the cause of this error.

Python 2.7

Your Environment

  • Zappa version used:0.45.1
  • Operating System and Python version: aws ami
  • The output of pip freeze:
    argcomplete==1.9.2
    backports.weakref==1.0.post1
    base58==0.2.4
    bleach==1.5.0
    boto3==1.4.8
    botocore==1.8.0
    certifi==2017.11.5
    cfn-flip==0.2.5
    chardet==3.0.4
    click==6.7
    docutils==0.14
    durationpy==0.5
    Flask==0.12.2
    funcsigs==1.0.2
    future==0.16.0
    futures==3.1.1
    hjson==3.0.1
    html5lib==0.9999999
    idna==2.6
    itsdangerous==0.24
    Jinja2==2.10
    jmespath==0.9.3
    kappa==0.6.0
    lambda-packages==0.19.0
    Markdown==2.6.9
    MarkupSafe==1.0
    mock==2.0.0
    numpy==1.13.3
    pbr==3.1.1
    placebo==0.8.1
    protobuf==3.5.0
    python-dateutil==2.6.1
    python-slugify==1.2.4
    PyYAML==3.12
    requests==2.18.4
    s3transfer==0.1.11
    six==1.11.0
    tensorflow==1.3.0
    tensorflow-tensorboard==0.1.8
    toml==0.9.3
    tqdm==4.19.1
    troposphere==2.1.0
    Unidecode==0.4.21
    urllib3==1.22
    Werkzeug==0.12
    wsgi-request-logger==0.4.6
    zappa==0.45.1
  • Your zappa_settings.py:
{
    "test": {
        "s3_bucket": <info removed>,
        "app_function": "app.app",
            "timeout_seconds": 300,
            "slim_handler": true,
            "memory_size": 1530,
            "use_precompiled_packages": true
     }
}
@brunnoattorre
Copy link

I had the same issue with the newest Zappa version.

@ngmcfarland
Copy link

I am having the same issue with version 0.45.1 as well. I am deploying from an Amazon Linux Docker image.

@jeffbryner
Copy link

FWIW I reverted to zappa==0.32.1 (aka the wayback machine), fought my way through pip check dependency hell and seemed to have landed at a stable platform. requirements.txt attached in case it sheds any light on things.
requirements.txt

@datascienceit
Copy link

Same issue here with 0.45.1

@titomiguelcosta
Copy link

Same here, also using 0.45.1

@rllin-fathom
Copy link

rllin-fathom commented Dec 17, 2017

I tried 0.32.1 but that only works with python 2 it seemed.

Using 0.43.1 seemed to move past this issue for me on python 3.6.3

@iandees
Copy link

iandees commented Jan 2, 2018

I'm also getting this. I've tried deploying versions all the way back to 0.43.1 and not seeing any improvement.

iandees added a commit to tilezen/tapalcatl-py that referenced this issue Jan 3, 2018
@iandees
Copy link

iandees commented Jan 28, 2018

I recently set up a new Zappa project using zappa==0.45.1 and it worked fine. Comparing the setup of the broken project with the new, working one, I saw that my old, broken-under-zappa-0.45.1 one was running with the python2.7 runtime setting in zappa_settings.json. Switching the broken one to use python3.6 made it work again with a recent zappa.

@scoates
Copy link
Collaborator

scoates commented Feb 25, 2018

@iandees: is this fixed in 0.45.1, then?

@aanchan
Copy link

aanchan commented Feb 28, 2018

@scoates I managed to fix my issue with zappa 0.45.1.
What I did after reading things in this issue:

  1. Install zappa 0.45.1 within the virtualenv. I am using Python 3.6.
  2. Do not, I repeat do not use sudo with pip install when installing stuff (zappa, sqlalchemy etc.)in the virtual env. Some of the packages get installed in the global python dist-packages.
  3. As a result on AWS the module handler.py cannot be loaded since it cannot find certain packages, e.g. builtins or werkzeug.

The error reporting on Zappa especially on the command line is super misleading since it always says "Congratulations! Your App is Live!". I'm thinking there should be some sort of environment check when packaging up the application and sending it to AWS?

@jeffbryner
Copy link

Oh, I love the idea of a sanity check before deploying! Sucks to find out only by testing that the deployment didn't work.

@scoates
Copy link
Collaborator

scoates commented Feb 28, 2018

Yeah, you definitely can't sudo pip … within a virtualenv and expect it to work within the virtualenv (sudo creates a new subshell and doesn't get your pip activated path).

There's some discussion on a post-deploy sanity check here: #1414

I think we can consider this issue closed. If not, please reopen.
(sudo pip … is a user error, and we can't do much about it beyond checking that things deployed sanely.)

@laudiacay
Copy link

Y'all should seriously consider adding a check for the correct python version in the zappa init script. Mine assumed I was using python2.7, when I was using 3.6, and this led to hours of confusion because the error messages were so undescriptive!

@trickidicki
Copy link

I have been struggling with this issue the past couple of days. Windows, Python 3.6.
Had to downgrade to Zappa==0.45.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests