Django AWS Elastic-Beanstalk WSGI.py配置

时间:2016-10-18 20:50:33

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

我目前正在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”

enter image description here

我将wsgi路径更改为 WSGIPath:pronet / 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

1 个答案:

答案 0 :(得分:0)

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