zappa / Zappa

Serverless Python
https://zappa.ws/zappa
MIT License
3.28k stars 364 forks source link

[Migrated] zappa update works from OSX, not from Ubuntu #417

Closed jneves closed 2 years ago

jneves commented 3 years ago

Originally from: https://github.com/Miserlou/Zappa/issues/1074 by aarcro

Context

When using zappa to deploy my project from OSX everything works as expected. When I run zappa update from an ubuntu 17.04 box running in EC2 I get the following exception in the first request to the lambda:

Traceback (most recent call last):
  File "/var/task/handler.py", line 505, in lambda_handler
  return LambdaHandler.lambda_handler(event, context)
  File "/var/task/handler.py", line 239, in lambda_handler
  handler = cls()
  File "/var/task/handler.py", line 145, in __init__
  wsgi_app_function = get_django_wsgi(self.settings.DJANGO_SETTINGS)
  File "/var/task/zappa/ext/django_zappa.py", line 20, in get_django_wsgi
  return get_wsgi_application()
  File "/tmp/webapp/django/core/wsgi.py", line 13, in get_wsgi_application
  django.setup(set_prefix=False)
  File "/tmp/webapp/django/__init__.py", line 27, in setup
  apps.populate(settings.INSTALLED_APPS)
  File "/tmp/webapp/django/apps/registry.py", line 85, in populate
  app_config = AppConfig.create(entry)
  File "/tmp/webapp/django/apps/config.py", line 94, in create
  module = import_module(entry)
  File "/var/lang/lib/python3.6/importlib/__init__.py", line 126, in import_module
  return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/tmp/webapp/push_notifications/__init__.py", line 4, in <module>
  __version__ = pkg_resources.require("django-push-notifications")[0].version
  File "/tmp/webapp/pkg_resources/__init__.py", line 972, in require
  needed = self.resolve(parse_requirements(requirements))
  File "/tmp/webapp/pkg_resources/__init__.py", line 858, in resolve
  raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pycparser' distribution was not found and is required by cffi

and TypeError: 'NoneType' object is not callable on every following request.

Expected Behavior

lambda function works after zappa update on Ubuntu/EC2

Actual Behavior

lambda does not function when updated from EC2

Possible Fix

Possibly user error, but I can't figure out why pycparser would be included when packaging on OSX and not on Ubuntu

I can see pycparser in my site-packages, but it's not in the Zip that I can download from lambda neither when build from OSX or Ubuntu.

Steps to Reproduce

  1. zappa update zappa_dev
  2. zappa tail -since 1m

Your Environment

apns2==0.3.0
appdirs==1.4.3
argcomplete==1.8.2
asn1crypto==0.22.0
base58==0.2.4
boto==2.47.0
boto3==1.4.5
botocore==1.5.40
certifi==2017.7.27.1
cffi==1.10.0
chardet==3.0.4
click==6.7
coreapi==2.3.0
coreschema==0.0.4
cryptography==1.9
defusedxml==0.5.0
Django==1.11.1
django-cacheops==3.2.1
django-constance==2.0.0
django-contact-form==1.4.1
django-debug-toolbar==1.8
django-filter==1.0.4
django-grappelli==2.10.1
django-localflavor==1.4.1
django-model-utils==3.0.0
django-picklefield==0.3.2
django-push-notifications==1.5.0
django-recurrence==1.4.1
django-redis==4.8.0
django-rest-swagger==2.1.2
django-ses==0.8.2
django-storages==1.6.3
django-waffle==0.12.0a1
djangorestframework==3.6.3
djangorestframework-jwt==1.10.0
docutils==0.14
durationpy==0.5
easy-thumbnails==2.4.1
facebook-sdk==2.0.0
funcy==1.7.5
future==0.16.0
futures==3.1.1
h2==2.6.2
hjson==3.0.0
hpack==3.0.0
hyper==0.7.0
hyperframe==3.2.0
idna==2.6
itypes==1.1.0
Jinja2==2.9.6
jmespath==0.9.3
kappa==0.6.0
lambda-packages==0.16.1
Markdown==2.6.8
MarkupSafe==1.0
oauthlib==2.0.2
olefile==0.44
openapi-codec==1.3.1
packaging==16.8
Pillow==4.1.1
placebo==0.8.1
psycopg2==2.7.1
pycparser==2.17
PyJWT==1.5.0
pyparsing==2.2.0
python-dateutil==2.6.1
python-slugify==1.2.4
python3-openid==3.1.0
pytz==2017.2
PyYAML==3.12
redis==2.10.5
requests==2.18.4
requests-oauthlib==0.8.0
rest-framework-auth0==0.4.5
s3transfer==0.1.10
simplejson==3.10.0
six==1.10.0
social-auth-app-django==1.2.0
social-auth-core==1.3.0
sqlparse==0.2.3
toml==0.9.2
tqdm==4.15.0
troposphere==1.9.5
Unidecode==0.4.21
uritemplate==3.0.0
urllib3==1.22
Werkzeug==0.12
wsgi-request-logger==0.4.6
zappa==0.43.2
---
zappa_dev:
    aws_region: us-east-1
    project_name: webapp
    # Set this in the environment now - tasks server won't have a config file
    # profile_name: petco_admin
    s3_bucket: zappa-dev-XXXXX
    slim_handler: false
    django_settings: webapp.settings
    domain: zappa-dev.petco.jbssolutions.com
    # Enable SSL
    certificate_arn: arn:aws:acm:us-east-1:XXXXX:certificate/XXXXX
    exclude:
      - "*.pyc"
      - "*.pyo"
      - "*.pyd"
      - "*.swp"
      - __pycache__
      - DB
      - media_files

    extra_permissions:
      - Effect: Allow
        Action: ["ses:GetSendQuota", "ses:SendRawEmail"]
        Resource: "*"

    vpc_config:
        SubnetIds: ["subnet-YYYYY", "subnet-XXXX"]
        SecurityGroupIds: ["sg-XXXX",]

    environment_variables:
       A_LOT: of things
monkut commented 2 years ago

considered stale.

closing.