【问题标题】:Django AWS Elastic-Beanstalk WSGI.py configurationDjango AWS Elastic-Beanstalk WSGI.py 配置
【发布时间】:2017-02-28 07:03:22
【问题描述】:

我目前正在 AWS Elastic-Beanstalk 上使用 python3 设置 django 应用程序,但在为应用程序配置 wsgi.py 文件时遇到问题。为什么我有错误:ERROR: Your WSGIPath refers to a file that does not exist.

运行 eb config 时,我将 wsgi 路径设置为 WSGIPath: pronet/pronet/src/pronet/wsgi.py

是我的 wsgi.py 脚本、eb config wsgi 设置有问题,还是没有安装 django 模块

WSGI.py 脚本

"""
WSGI config for pronet project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pronet.settings.production")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

# Wrap werkzeug debugger if DEBUG is on
from django.conf import settings
if settings.DEBUG:
    try:
        import django.views.debug
        import six
        from werkzeug.debug import DebuggedApplication

        def null_technical_500_response(request, exc_type, exc_value, tb):
            six.reraise(exc_type, exc_value, tb)

        django.views.debug.technical_500_response = null_technical_500_response
        application = DebuggedApplication(application, evalex=True,
                                          # Turning off pin security as DEBUG is True
                                          pin_security=False)
    except ImportError:
        pass

ElasticbeanStalk eb 日志 输出文件

[Tue Oct 18 18:59:52.882790 2016] [:error] [pid 25763] 
[remote 172.31.5.99:148] mod_wsgi (pid=25763): 
    Exception occurred processing WSGI script 
'/opt/python/current/app/pronet/src/pronet/wsgi.py'.


[Tue Oct 18 20:01:21.096064 2016] [:error] [pid 25763] 
    [remote 172.31.46.245:148] ImportError: No module named 'django'
[Tue Oct 18 20:01:21.478180 2016] [:error] [pid 25763] 
    [remote 172.31.46.245:60132] mod_wsgi (pid=25763): 
    Target WSGI script '/opt/python/current/app/pronet/src/pronet/wsgi.py' 
    cannot be loaded as PytExamine: sing WSGI script  '/opt/python/current/app/pronet/src/pronet/wsgi.py'.

项目目录“Pronet/pronet/src/pronet/wsgi.py”

我将 wsgi 路径更改为 WSGIPath:pronett/src/pronet/wsgi.py,现在我在 eb 日志中收到了这条消息。这是否意味着找到了wsgi.py?

[Tue Oct 18 20:53:09.711239 2016] [so:warn] [pid 31697] AH01574: module wsgi_module is already loaded, skipping

【问题讨论】:

  • 这篇文章对您有帮助吗? Link

标签: python django amazon-web-services amazon-elastic-beanstalk django-wsgi


【解决方案1】:

这通常是由于您的应用目录的结构方式造成的。大多数情况下,这是由于您用于压缩文件夹以进行部署的方法。不要压缩父文件夹,而是尝试选择根目录中的项目然后压缩。

【讨论】:

    猜你喜欢
    • 2019-12-02
    • 2020-08-27
    • 2017-05-21
    • 2016-12-08
    • 2013-04-11
    • 2017-11-20
    • 2012-12-14
    • 2020-09-21
    • 2019-08-06
    相关资源
    最近更新 更多