You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署现有Django应用到Beanstalk遇ModuleNotFoundError错误求助

解决AWS Elastic Beanstalk部署Django时的ModuleNotFoundError: No module named 'application'错误

核心问题

你的django.config中配置的WSGIPath指向了错误的模块路径,导致Elastic Beanstalk无法找到正确的WSGI应用入口。

你当前的配置是:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: ebTestDjango.wsgi:application

但你的项目中WSGI文件实际位于pytrade/wsgi.py,对应的模块路径应该是pytrade.wsgi,而非ebTestDjango.wsgi。

修复步骤

修改.ebextensions/django.config中的WSGIPath配置为:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: pytrade.wsgi:application

关键逻辑说明

Elastic Beanstalk的WSGIPath需要填写的是Python模块路径,而非文件系统路径:

  • pytrade.wsgi对应项目根目录下的pytrade/wsgi.py文件
  • :application是该文件中定义的WSGI应用对象(你的wsgi.py中已经正确定义了这个对象)

额外验证项

  • 确认pytrade目录下存在__init__.py文件(你的目录结构中已包含),确保该目录能被识别为Python模块
  • 检查requirements.txt是否包含Django及项目依赖,Elastic Beanstalk会在部署时自动安装这些依赖
  • 本地运行python manage.py runserver确认项目本身可正常启动

内容的提问来源于stack exchange,提问作者user3241846

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 07:34:59