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 #1222

Closed
brandonhilkert opened this Issue Nov 8, 2017 · 11 comments

Comments

Projects
None yet
6 participants
@brandonhilkert

brandonhilkert commented Nov 8, 2017

Context

Deploying a new Flask Python 2.7 app (we have another one working well) and getting this error.

Expected Behavior

The error should not be thrown

Actual Behavior

[1510159074562] Unable to import module 'handler': No module named builtins

Your Environment

  • Zappa version used: 0.45.1
  • Operating System and Python version: OSX w/ python 2.7.14
  • The output of pip freeze:
aniso8601==1.3.0
argcomplete==1.9.2
backports.csv==1.0.5
-e git+git@github.com:Bark-us/bark-nlp.git@4dbab62dc5bc154d0caf6344ca70b698644e2338#egg=bark_nlp
base58==0.2.4
boto3==1.4.7
botocore==1.7.41
cachetools==2.0.1
certifi==2017.11.5
cffi==1.11.2
chardet==3.0.4
-e git+git@github.com:Bark-us/classify-text.git@ee3d97d2b29a723f7963c1b3078cee69ad63aaa7#egg=classify_text
click==6.7
cymem==1.31.2
cytoolz==0.8.2
decorator==4.1.2
dill==0.2.7.1
docutils==0.14
durationpy==0.5
emoji==0.4.5
Flask==0.12.2
Flask-RESTful==0.3.6
ftfy==4.4.3
future==0.16.0
futures==3.1.1
fuzzywuzzy==0.15.1
-e git+git@github.com:Bark-us/gglsbl.git@72a02c4c01cf87fd5a9b1fa31c8fd70310b58110#egg=gglsbl
google-api-python-client==1.6.4
hjson==3.0.1
html5lib==0.999999999
httplib2==0.10.3
idna==2.6
ijson==2.3
itsdangerous==0.24
Jinja2==2.9.6
jmespath==0.9.3
joblib==0.10.0
kappa==0.6.0
lambda-packages==0.19.0
marisa-trie==0.7.4
MarkupSafe==1.0
murmurhash==0.26.4
networkx==2.0
newrelic==2.96.0.80
nltk==3.2
numpy==1.13.3
oauth2client==3.0.0
oauthlib==2.0.6
pandas==0.18.1
pathlib==1.0.1
plac==0.9.6
placebo==0.8.1
preshed==1.0.0
pyasn1==0.3.7
pyasn1-modules==0.1.5
pycparser==2.18
pyemd==0.4.4
Pyphen==0.9.4
python-dateutil==2.6.1
python-Levenshtein==0.12.0
python-slugify==1.2.4
pytz==2017.3
PyYAML==3.12
regex==2017.9.23
requests==2.18.4
requests-oauthlib==0.8.0
rsa==3.4.2
s3transfer==0.1.11
scikit-learn==0.18.1
scipy==1.0.0
six==1.11.0
spacy==1.9.0
termcolor==1.1.0
textblob==0.13.0
-e git+git@github.com:Bark-us/textstat.git@f94746d5596c10ab7e46ef78b62b89224d044937#egg=textstat
thinc==6.5.2
toml==0.9.3
toolz==0.8.2
tqdm==4.19.1
troposphere==2.0.2
twython==3.6.0
ujson==1.35
Unidecode==0.4.21
uritemplate==3.0.0
urllib3==1.22
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==0.12
wrapt==1.10.11
wsgi-request-logger==0.4.6
xgboost==0.6a2
zappa==0.45.1
  • Your zappa_settings.py:
{
    "dev": {
        "project_name": "bark-api-classify",
        "app_function": "api.app",
        "aws_region": "us-east-1",
        "profile_name": "default",
        "exclude": ["config", "docs", "scripts"],
        "manage_roles": false,
        "role_name": "bark-api-dev-ZappaLambdaExecutionRole",
        "runtime": "python2.7",
        "slim_handler": true,
        "s3_bucket": "zappa-[redacted]",
        "timeout_seconds": 300,
    }
}
@brandonhilkert

This comment has been minimized.

Show comment
Hide comment
@brandonhilkert

brandonhilkert Nov 8, 2017

If I change slim_handler to true in the settings and remove a bunch of dependencies get the package < 50MB, it works as expected. It feels like there's something missing or getting overwritten. Could it be a package thing?

brandonhilkert commented Nov 8, 2017

If I change slim_handler to true in the settings and remove a bunch of dependencies get the package < 50MB, it works as expected. It feels like there's something missing or getting overwritten. Could it be a package thing?

@brandonhilkert

This comment has been minimized.

Show comment
Hide comment
@brandonhilkert

brandonhilkert Nov 8, 2017

Recreated the virtual env with the name venv and removed exclusions and all works now.

brandonhilkert commented Nov 8, 2017

Recreated the virtual env with the name venv and removed exclusions and all works now.

@brandonhilkert

This comment has been minimized.

Show comment
Hide comment
@brandonhilkert

brandonhilkert Nov 8, 2017

FWIW - reverting zappa to version 0.44.3 fixed the issue. The previous comment wasn't enough when using the lastest version.

brandonhilkert commented Nov 8, 2017

FWIW - reverting zappa to version 0.44.3 fixed the issue. The previous comment wasn't enough when using the lastest version.

@GregDubbin

This comment has been minimized.

Show comment
Hide comment
@GregDubbin

GregDubbin Dec 29, 2017

I've encountered this error (Unable to import module 'handler': No module named builtins) recently and managed to fix it by moving all of the modules in env/lib/dist-packages to env/lib/site-packages. I haven't done any additional testing to figure out why this is a problem for the latest version of zappa but not earlier ones.

GregDubbin commented Dec 29, 2017

I've encountered this error (Unable to import module 'handler': No module named builtins) recently and managed to fix it by moving all of the modules in env/lib/dist-packages to env/lib/site-packages. I haven't done any additional testing to figure out why this is a problem for the latest version of zappa but not earlier ones.

@tay-bird

This comment has been minimized.

Show comment
Hide comment
@tay-bird

tay-bird Dec 30, 2017

I've been running into this issue zappa==0.45.1 as well. My workaround is to install zappa into the virtualenv along with any other dependencies.

tay-bird commented Dec 30, 2017

I've been running into this issue zappa==0.45.1 as well. My workaround is to install zappa into the virtualenv along with any other dependencies.

kontrollanten added a commit to hitta-skyddsrum/services that referenced this issue Feb 10, 2018

@bogdanalov

This comment has been minimized.

Show comment
Hide comment
@bogdanalov

bogdanalov May 3, 2018

Guys, why this is still happening?? Degrading it doesn't fix the issue at all

bogdanalov commented May 3, 2018

Guys, why this is still happening?? Degrading it doesn't fix the issue at all

@Shaun1

This comment has been minimized.

Show comment
Hide comment
@Shaun1

Shaun1 May 14, 2018

Also getting this error in zappa==0.45.1

Shaun1 commented May 14, 2018

Also getting this error in zappa==0.45.1

@Shaun1

This comment has been minimized.

Show comment
Hide comment
@Shaun1

Shaun1 May 14, 2018

@bogdanalov I had to do pip uninstall zappa on my system pip installation and then pip install zappa in with my virtualenv activated and it was fixed. Seems a little odd though.

Shaun1 commented May 14, 2018

@bogdanalov I had to do pip uninstall zappa on my system pip installation and then pip install zappa in with my virtualenv activated and it was fixed. Seems a little odd though.

@bogdanalov

This comment has been minimized.

Show comment
Hide comment
@bogdanalov

bogdanalov Jun 29, 2018

@Shaun1 Thanks. I found another issue on Amazon Linux. When installing packages in the virtualenv it is installing them in the dist-packages folder instead of the site-packages one. Move all packages to the site-packages folder and empty the dist-packages one. The thing is you should make this steps everytime when adding new package...

bogdanalov commented Jun 29, 2018

@Shaun1 Thanks. I found another issue on Amazon Linux. When installing packages in the virtualenv it is installing them in the dist-packages folder instead of the site-packages one. Move all packages to the site-packages folder and empty the dist-packages one. The thing is you should make this steps everytime when adding new package...

@bogdanalov

This comment has been minimized.

Show comment
Hide comment
@bogdanalov

bogdanalov Jun 29, 2018

Turning slim_handler to true and uninstalling zappa from the virtualenv somehow works for me.. I have deployed some Lambda functions like this and it is working.

bogdanalov commented Jun 29, 2018

Turning slim_handler to true and uninstalling zappa from the virtualenv somehow works for me.. I have deployed some Lambda functions like this and it is working.

@laudecay

This comment has been minimized.

Show comment
Hide comment
@laudecay

laudecay Sep 6, 2018

I'm currently having this same issue on python3.6/Ubuntu Xenial, and none of the fixes are working. The commands I'm running are as follows, where $django_dir is the directory that has urls.py and stuff in it.

# clear out any old zappa installs from any version of pip
pip uninstall zappa; pip3 uninstall zappa; pip3.6 uninstall zappa
cd $django_dir/..
virtualenv my-env --python=$(which python3.6)
. my-env/bin/activate
pip install -r requirements.txt  # to install zappa and django
cd $django_dir
zappa init
zappa update

laudecay commented Sep 6, 2018

I'm currently having this same issue on python3.6/Ubuntu Xenial, and none of the fixes are working. The commands I'm running are as follows, where $django_dir is the directory that has urls.py and stuff in it.

# clear out any old zappa installs from any version of pip
pip uninstall zappa; pip3 uninstall zappa; pip3.6 uninstall zappa
cd $django_dir/..
virtualenv my-env --python=$(which python3.6)
. my-env/bin/activate
pip install -r requirements.txt  # to install zappa and django
cd $django_dir
zappa init
zappa update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment