Python Django内部服务器500错误AWS Elastic Beanstalk问题

Python Django内部服务器500错误AWS Elastic Beanstalk问题,python,django,amazon-web-services,internal-server-error,http-status-code-500,Python,Django,Amazon Web Services,Internal Server Error,Http Status Code 500,如何修复AWS eb部署应用程序上的Django Internal Server 500错误 我是否需要在base.py文件中更改允许的主机,以便在elasticbeanstalk中拥有ec2的ip地址 # SECURITY WARNING: keep the secret key used in production secret! # Raises ImproperlyConfigured exception if SECRET_KEY not in os.environ SECRET_KE

如何修复AWS eb部署应用程序上的Django Internal Server 500错误

我是否需要在base.py文件中更改允许的主机,以便在elasticbeanstalk中拥有ec2的ip地址

# SECURITY WARNING: keep the secret key used in production secret!
# Raises ImproperlyConfigured exception if SECRET_KEY not in os.environ
SECRET_KEY = env('SECRET_KEY')

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = (
    'django.contrib.auth',
    'django_admin_bootstrapped',
    'django.contrib.admin',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

我启用了调试并运行了eb配置和eb日志。eb部署值显示在下面,而eb日志值显示在下面。如何解决“没有名为django的模块”的问题

下面提供了eb日志的输出

============= i-0b11de8b8521ea5c0 ==============
-------------------------------------
/var/log/httpd/error_log
-------------------------------------
[Thu Oct 20 17:46:59.414032 2016] [:error] [pid 11268] 
[remote 172.31.5.67:41390] Traceback (most recent call last):

[Thu Oct 20 17:46:59.414077 2016] [:error] [pid 11268] 
[remote 172.31.5.67:41390]   File "/opt/python/current/app/pronet/src/pronet/wsgi.py", line 12, in <module>

[Thu Oct 20 17:46:59.414083 2016] [:error] [pid 11268] 
[remote 172.31.5.67:41390]     from django.core.wsgi import get_wsgi_application

[Thu Oct 20 17:46:59.414104 2016] [:error] [pid 11268] 
[remote 172.31.5.67:41390] ImportError: No module named 'django'

[Thu Oct 20 17:47:00.046644 2016] [:error] [pid 11268] 
[remote 172.31.5.67:43182] mod_wsgi (pid=11268): Target WSGI script '/opt/python/current/app/pronet/src/pronet/wsgi.py' cannot be loaded as Python module.

[Thu Oct 20 17:47:00.046704 2016] [:error] [pid 11268] 
[remote 172.31.5.67:43182] mod_wsgi (pid=11268): Exception occurred processing WSGI script '/opt/python/current/app/pronet/src/pronet/wsgi.py'.

[Thu Oct 20 17:47:00.046738 2016] [:error] [pid 11268] 
[remote 172.31.5.67:43182] Traceback (most recent call last):

[Thu Oct 20 17:47:00.046784 2016] [:error] [pid 11268] 
[remote 172.31.5.67:43182]   File "/opt/python/current/app/pronet/src/pronet/wsgi.py", line 12, in <module>

[Thu Oct 20 17:47:00.046789 2016] [:error] [pid 11268] 
[remote 172.31.5.67:43182]     from django.core.wsgi import get_wsgi_application

[Thu Oct 20 17:47:00.046810 2016] [:error] [pid 11268] 
[remote 172.31.5.67:43182] ImportError: No module named 'django'

[Thu Oct 20 17:47:01.340552 2016] [:error] [pid 11268] 
[remote 172.31.5.67:43182] mod_wsgi (pid=11268): Target WSGI script '/opt/python/current/app/pronet/src/pronet/wsgi.py' cannot be loaded as Python module.

[Thu Oct 20 17:47:01.340603 2016] [:error] [pid 11268] 
[remote 172.31.5.67:43182] mod_wsgi (pid=11268): Exception occurred processing WSGI script '/opt/python/current/app/pronet/src/pronet/wsgi.py'.

[Thu Oct 20 17:47:01.340653 2016] [:error] [pid 11268] [remote 172.31.5.67:43182] Traceback (most recent call last):

[Thu Oct 20 17:47:01.340701 2016] [:error] [pid 11268] 
[remote 172.31.5.67:43182]   File "/opt/python/current/app/pronet/src/pronet/wsgi.py", line 12, in <module>

[Thu Oct 20 17:47:01.340706 2016] [:error] [pid 11268] 
[remote 172.31.5.67:43182]     from django.core.wsgi import get_wsgi_application

[Thu Oct 20 17:47:01.340728 2016] [:error] [pid 11268] 
[remote 172.31.5.67:43182] ImportError: No module named 'django'
=============i-0b11de8b8521ea5c0==============
-------------------------------------
/var/log/httpd/error\u log
-------------------------------------
[2016年10月20日星期四17:46:59.414032][:错误][pid 11268]
[远程172.31.5.67:41390]回溯(最近一次呼叫最后一次):
[2016年10月20日星期四17:46:59.414077][:错误][pid 11268]
[远程172.31.5.67:41390]文件“/opt/python/current/app/pronet/src/pronet/wsgi.py”,第12行,在
[2016年10月20日星期四17:46:59.414083][:错误][pid 11268]
[remote 172.31.5.67:41390]来自django.core.wsgi导入get_wsgi_应用程序
[2016年10月20日星期四17:46:59.414104][:错误][pid 11268]
[远程172.31.5.67:41390]导入错误:没有名为“django”的模块
[2016年10月20日星期四17:47:00.046644][:错误][pid 11268]
[remote 172.31.5.67:43182]mod_wsgi(pid=11268):无法将目标wsgi脚本“/opt/python/current/app/pronet/src/pronet/wsgi.py”作为python模块加载。
【2016年10月20日星期四17:47:00.046704】【错误】【pid 11268】
[remote 172.31.5.67:43182]mod_wsgi(pid=11268):处理wsgi脚本“/opt/python/current/app/pronet/src/pronet/wsgi.py”时发生异常。
【2016年10月20日星期四17:47:00.046738】【错误】【pid 11268】
[远程172.31.5.67:43182]回溯(最近一次呼叫最后一次):
【2016年10月20日星期四17:47:00.046784】【错误】【pid 11268】
[远程172.31.5.67:43182]文件“/opt/python/current/app/pronet/src/pronet/wsgi.py”,第12行,在
【2016年10月20日星期四17:47:00.046789】【错误】【pid 11268】
[remote 172.31.5.67:43182]来自django.core.wsgi导入get_wsgi_应用程序
【2016年10月20日星期四17:47:00.046810】【错误】【pid 11268】
[remote 172.31.5.67:43182]导入错误:没有名为“django”的模块
[2016年10月20日星期四17:47:01.340552][:错误][pid 11268]
[remote 172.31.5.67:43182]mod_wsgi(pid=11268):无法将目标wsgi脚本“/opt/python/current/app/pronet/src/pronet/wsgi.py”作为python模块加载。
【2016年10月20日星期四17:47:01.340603】【错误】【pid 11268】
[remote 172.31.5.67:43182]mod_wsgi(pid=11268):处理wsgi脚本“/opt/python/current/app/pronet/src/pronet/wsgi.py”时发生异常。
[2016年10月20日星期四17:47:01.340653][:错误][pid 11268][remote 172.31.5.67:43182]回溯(最近一次呼叫最后一次):
【2016年10月20日星期四17:47:01.340701】【错误】【pid 11268】
[远程172.31.5.67:43182]文件“/opt/python/current/app/pronet/src/pronet/wsgi.py”,第12行,在
【2016年10月20日星期四17:47:01.340706】【错误】【pid 11268】
[remote 172.31.5.67:43182]来自django.core.wsgi导入get_wsgi_应用程序
【2016年10月20日星期四17:47:01.340728】【错误】【pid 11268】
[remote 172.31.5.67:43182]导入错误:没有名为“django”的模块
链接到github项目。您可以在此处查看所有代码

你是这样做的吗

pip freeze > requirements.txt
如果您没有这样做,AWS将不会知道它应该这样做。

在我的例子中,sqllite出现错误

从settings.py中删除数据库设置,然后尝试部署

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

然后我配置了AWS RDS

您是否在
设置.py中启用了调试功能?如果是这样的话,那里的回溯是什么?启用
DEBUG
查看控制台中的错误我启用了调试,但我仍然得到相同的“django module not found error”。知道为什么吗?我也是这样。OS sqlite版本对于我使用的适配器来说太低了。。
pip freeze > requirements.txt
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}