使用Zappa部署Django至Lambda时出现Django未找到错误
Zappa部署Django应用报错:ModuleNotFoundError: No module named 'django'
我用Zappa部署Django应用,因依赖包总大小超过1GB,已在zappa_settings.py中配置slim_handler: true,并通过"ephemeral_storage": {"Size": 10240}将Lambda临时存储扩容至10GB,但CloudWatch日志仍返回django not found错误。
相关配置信息
zappa_settings.py 文件内容
{ "test-staging": { "ephemeral_storage": {"Size": 10240}, "aws_region": "us-west-1", "django_settings": "lu_development.settings", "profile_name": "default", "project_name": "linkedunion-bac", "runtime": "python3.10", "s3_bucket": "zappa-sultan-test-migration", "slim_handler": true } }
虚拟环境已安装的依赖包
aioredis==1.3.1 amqp==2.6.1 anyio==4.0.0 argcomplete==3.2.1 asgiref==3.7.2 async-timeout==4.0.3 attrs==23.1.0 autobahn==23.6.2 Automat==22.10.0 autopep8==2.0.4 backoff==2.2.1 billiard==3.6.4.0 boto==2.49.0 boto3==1.24.8 botocore==1.27.8 celery==4.4.3 certifi==2023.7.22 cffi==1.15.1 cfn-flip==1.3.0 channels==3.0.5 chardet==3.0.4 click==8.1.7 constantly==15.1.0 cryptography==41.0.3 daphne==3.0.2 Deprecated==1.2.14 Django==4.0.10 django-cacheops==7.0.1 django-cors-headers==3.14.0 django-debug-toolbar==4.0.0 django-environ==0.4.5 django-mysql==3.9.0 django-ninja==0.22.2 django-redis==5.3.0 django-simple-history==2.12.0 django-storages==1.10 djangorestframework==3.14.0 djangorestframework-simplejwt==4.6.0 durationpy==0.6 exceptiongroup==1.1.3 factory-boy==3.3.0 Faker==19.3.1 funcy==1.18 gcloud==0.18.3 geographiclib==2.0 geopy==2.4.0 googleapis-common-protos==1.52.0 grpcio==1.60.0 gunicorn==20.0.4 h11==0.14.0 hiredis==2.2.3 hjson==3.1.0 httpcore==0.17.3 httplib2==0.22.0 httpx==0.24.1 hyperlink==21.0.0 idna==2.10 importlib-metadata==6.11.0 incremental==22.10.0 jmespath==0.10.0 JSON-log-formatter==0.5.2 jws==0.1.3 kappa==0.6.0 kombu==4.6.11 markdown-it-py==3.0.0 MarkupSafe==2.1.3 mdurl==0.1.2 mysql-connector==2.2.9 mysql-connector-python==8.0.21 mysqlclient==2.0.1 numpy==1.25.2 oauth2client==4.1.2 onesignal-sdk==2.0.0 opentelemetry-api==1.19.0 opentelemetry-distro==0.40b0 opentelemetry-exporter-otlp==1.19.0 opentelemetry-exporter-otlp-proto-common==1.19.0 opentelemetry-exporter-otlp-proto-grpc==1.19.0 opentelemetry-exporter-otlp-proto-http==1.19.0 opentelemetry-instrumentation==0.40b0 opentelemetry-instrumentation-celery==0.40b0 opentelemetry-instrumentation-dbapi==0.40b0 opentelemetry-instrumentation-django==0.40b0 opentelemetry-instrumentation-logging==0.40b0 opentelemetry-instrumentation-psycopg2==0.40b0 opentelemetry-instrumentation-redis==0.40b0 opentelemetry-instrumentation-requests==0.40b0 opentelemetry-instrumentation-urllib3==0.40b0 opentelemetry-instrumentation-wsgi==0.40b0 opentelemetry-proto==1.19.0 opentelemetry-sdk==1.19.0 opentelemetry-semantic-conventions==0.40b0 opentelemetry-util-http==0.40b0 pandas==2.0.3 pdf2image==1.16.3 pep8==1.7.1 Pillow==10.0.1 placebo==0.9.0 protobuf==3.20.3 pyasn1==0.5.0 pyasn1-modules==0.3.0 pycodestyle==2.11.0 pycparser==2.21 pycryptodome==3.10.1 pydantic==1.9.1 Pygments==2.17.2 PyJWT==2.8.0 pymssql==2.2.5 pyOpenSSL==23.2.0 pyparsing==3.1.1 pypng==0.20220715.0 Pyrebase4==4.4.1 python-dateutil==2.8.2 python-jwt==2.0.1 python-magic==0.4.27 python-memcached==1.59 python-slugify==8.0.1 pytz==2023.3 PyYAML==6.0.1 qrcode==7.4.2 querystring-parser==1.2.4 redis==4.6.0 requests==2.25.0 requests-toolbelt==0.9.1 rich==13.5.3 rsa==4.9 s3transfer==0.6.2 sentry-sdk==1.9.8 service-identity==23.1.0 six==1.16.0 sniffio==1.3.0 sqlparse==0.4.1 text-unidecode==1.3 toml==0.10.2 tomli==2.0.1 tqdm==4.66.1 troposphere==4.5.3 twilio==7.15.3 Twisted==23.8.0 txaio==23.1.1 typing_extensions==4.7.1 tzdata==2023.3 tzlocal==5.0.1 urllib3==1.26.16 vine==1.3.0 Werkzeug==3.0.1 wrapt==1.16.0 zappa==0.58.0 zipp==3.17.0 zope.interface==6.0
CloudWatch错误日志
[ERROR] ModuleNotFoundError: No module named 'django' Traceback (most recent call last): File "/var/task/handler.py", line 657, in lambda_handler return LambdaHandler.lambda_handler(event, context) File "/var/task/handler.py", line 241, in lambda_handler handler = global_handler or cls() File "/var/task/handler.py", line 150, in __init__ wsgi_app_function = get_django_wsgi(self.settings.DJANGO_SETTINGS) File "/var/task/zappa/ext/django_zappa.py", line 9, in get_django_wsgi from django.core.wsgi import get_wsgi_application
内容的提问来源于stack exchange,提问作者Sultan Muhammad
相关产品推荐
相关产品推荐

