django openshift导入错误

时间:2013-07-31 11:33:27

标签: django openshift

我在将我的django项目移动到openshift时遇到了问题。我克隆了openshift应用程序。将我的django项目复制到/ wsgi / digrin /我的django项目中的openshift应用程序:digrin我的django应用程序:注册,digrin,股票。

wsgi
├── digrin
│   ├── digrin (settings.py here)
│   ├── registration
│   └── stocks
├── openshift (settings.py here)
└── static

当我运行“rhc tail -a digrin”时,我收到以下错误:

==> python/logs/error_log-20130718-000000-EST <==
[Thu Jul 18 16:15:39 2013] [error] [client 127.5.108.1]     self.load_middleware()
[Thu Jul 18 16:15:39 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/core/handlers/base.py", line 39, in load_middleware
[Thu Jul 18 16:15:39 2013] [error] [client 127.5.108.1]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Thu Jul 18 16:15:39 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/utils/functional.py", line 184, in inner
[Thu Jul 18 16:15:39 2013] [error] [client 127.5.108.1]     self._setup()
[Thu Jul 18 16:15:39 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/conf/__init__.py", line 42, in _setup
[Thu Jul 18 16:15:39 2013] [error] [client 127.5.108.1]     self._wrapped = Settings(settings_module)
[Thu Jul 18 16:15:39 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/conf/__init__.py", line 95, in __init__
[Thu Jul 18 16:15:39 2013] [error] [client 127.5.108.1]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Thu Jul 18 16:15:39 2013] [error] [client 127.5.108.1] ImportError: Could not import settings 'digrin.settings' (Is it on sys.path?): No module named settings

==> python/logs/error_log-20130731-000000-EST <==
[Wed Jul 31 07:21:39 2013] [error] [client 127.5.108.1]     self.load_middleware()
[Wed Jul 31 07:21:39 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/core/handlers/base.py", line 39, in load_middleware
[Wed Jul 31 07:21:39 2013] [error] [client 127.5.108.1]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Wed Jul 31 07:21:39 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/utils/functional.py", line 184, in inner
[Wed Jul 31 07:21:39 2013] [error] [client 127.5.108.1]     self._setup()
[Wed Jul 31 07:21:39 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/conf/__init__.py", line 42, in _setup
[Wed Jul 31 07:21:39 2013] [error] [client 127.5.108.1]     self._wrapped = Settings(settings_module)
[Wed Jul 31 07:21:39 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/conf/__init__.py", line 95, in __init__
[Wed Jul 31 07:21:39 2013] [error] [client 127.5.108.1]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Wed Jul 31 07:21:39 2013] [error] [client 127.5.108.1] ImportError: Could not import settings 'digrin.settings' (Is it on sys.path?): No module named openshiftlibs

==> python/logs/access_log-20130626-000000-EST <==
95.102.217.225 - - [26/Jun/2013:14:31:00 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
95.102.217.225 - - [26/Jun/2013:14:31:04 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
95.102.217.225 - - [26/Jun/2013:14:50:55 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
95.102.217.225 - - [26/Jun/2013:15:43:53 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
95.102.217.225 - - [26/Jun/2013:15:49:13 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; 
rv:21.0) Gecko/20100101 Firefox/21.0"
95.102.217.225 - - [26/Jun/2013:15:49:30 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
95.102.217.225 - - [26/Jun/2013:15:49:38 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
95.102.217.225 - - [26/Jun/2013:15:56:42 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
95.102.217.225 - - [26/Jun/2013:16:37:45 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
95.102.217.225 - - [26/Jun/2013:17:28:05 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"

==> python/logs/access_log-20130627-000000-EST <==
95.102.203.230 - - [27/Jun/2013:05:49:32 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0"
95.102.203.230 - - [27/Jun/2013:05:49:34 -0400] "GET /favicon.ico HTTP/1.1" 500 627 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0"

==> python/logs/error_log-20130627-000000-EST <==
[Thu Jun 27 05:49:34 2013] [error] [client 127.5.108.1]     self.load_middleware()
[Thu Jun 27 05:49:34 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/core/handlers/base.py", line 39, in load_middleware
[Thu Jun 27 05:49:34 2013] [error] [client 127.5.108.1]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Thu Jun 27 05:49:34 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/utils/functional.py", line 184, in inner
[Thu Jun 27 05:49:34 2013] [error] [client 127.5.108.1]     self._setup()
[Thu Jun 27 05:49:34 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/conf/__init__.py", line 42, in _setup
[Thu Jun 27 05:49:34 2013] [error] [client 127.5.108.1]     self._wrapped = Settings(settings_module)
[Thu Jun 27 05:49:34 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/conf/__init__.py", line 95, in __init__
[Thu Jun 27 05:49:34 2013] [error] [client 127.5.108.1]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Thu Jun 27 05:49:34 2013] [error] [client 127.5.108.1] ImportError: Could not import settings 'digrin.settings' (Is it on sys.path?): No module named settings

==> python/logs/access_log-20130719-000000-EST <==
95.102.233.230 - - [19/Jul/2013:12:55:59 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
95.102.233.230 - - [19/Jul/2013:12:56:20 -0400] "GET / HTTP/1.1" 200 62 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
95.102.233.230 - - [19/Jul/2013:12:56:28 -0400] "GET /admin HTTP/1.1" 301 - "http://digrin-lucas03.rhcloud.com/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
95.102.233.230 - - [19/Jul/2013:12:56:28 -0400] "GET /admin/ HTTP/1.1" 200 1896 "http://digrin-lucas03.rhcloud.com/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
95.102.233.230 - - [19/Jul/2013:12:56:30 -0400] "GET /static/admin/css/base.css HTTP/1.1" 404 316 "http://digrin-lucas03.rhcloud.com/admin/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
95.102.233.230 - - [19/Jul/2013:12:56:30 -0400] "GET /static/admin/css/login.css HTTP/1.1" 404 317 "http://digrin-lucas03.rhcloud.com/admin/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
95.102.233.230 - - [19/Jul/2013:12:56:35 -0400] "GET /
 HTTP/1.1" 200 62 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
95.102.233.230 - - [19/Jul/2013:12:56:52 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
95.102.233.230 - - [19/Jul/2013:13:02:02 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
10.90.135.25 - - [19/Jul/2013:18:09:12 -0400] "GET / HTTP/1.1" 500 627 "-" "Ruby"

==> python/logs/error_log-20130717-000000-EST <==
[Wed Jul 17 07:06:17 2013] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:openshift_t:s0:c2,c733
[Wed Jul 17 07:06:17 2013] [notice] Digest: generating secret for digest authentication ...
[Wed Jul 17 07:06:17 2013] [notice] Digest: done
[Wed Jul 17 07:06:18 2013] [notice] Apache/2.2.15 (Unix) mod_wsgi/3.2 Python/2.6.6 configured -- resuming normal operations

==> python/logs/error_log-20130626-000000-EST <==
[Wed Jun 26 17:28:05 2013] [error] [client 127.5.108.1]     self.load_middleware()
[Wed Jun 26 17:28:05 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/core/handlers/base.py", line 39, in load_middleware
[Wed Jun 26 17:28:05 2013] [error] [client 127.5.108.1]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Wed Jun 26 17:28:05 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/utils/functional.py", line 184, in inner
[Wed Jun 26 17:28:05 2013] [error] [client 127.5.108.1]     self._setup()
[Wed Jun 26 17:28:05 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/conf/__init__.py", line 42, in _setup
[Wed Jun 26 17:28:05 2013] [error] [client 127.5.108.1]     self._wrapped = Settings(settings_module)
[Wed Jun 26 17:28:05 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/conf/__init__.py", line 95, in __init__
[Wed Jun 26 17:28:05 2013] [error] [client 127.5.108.1]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Wed Jun 26 17:28:05 2013] [error] [client 127.5.108.1] ImportError: Could not import settings 'digrin.settings' (Is it on sys.path?): No module named settings

==> python/logs/access_log-20130731-000000-EST <==
188.167.64.82 - - [31/Jul/2013:07:03:35 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
188.167.64.82 - - [31/Jul/2013:07:05:35 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
188.167.64.82 - - [31/Jul/2013:07:05:40 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
188.167.64.82 - - [31/Jul/2013:07:05:40 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
188.167.64.82 - - [31/Jul/2013:07:05:41 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
188.167.64.82 - - [31/Jul/2013:07:05:49 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
188.167.64.82 - - [31/Jul/2013:07:06:15 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
188.167.64.82 - - [31/Jul/2013:07:06:27 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
127.0.0.1 - - [31/Jul/2013:07:20:44 -0400] "HEAD / HTTP/1.1" 500 - "-" "Ruby"
188.167.64.82 - - [31/Jul/2013:07:21:39 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; 
rv:22.0) Gecko/20100101 Firefox/22.0"

==> python/logs/error_log-20130719-000000-EST <==
[Fri Jul 19 18:09:15 2013] [error] [client 127.5.108.1]     self.load_middleware()
[Fri Jul 19 18:09:15 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/core/handlers/base.py", line 39, in load_middleware
[Fri Jul 19 18:09:15 2013] [error] [client 127.5.108.1]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Fri Jul 19 18:09:15 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/utils/functional.py", line 184, in inner
[Fri Jul 19 18:09:15 2013] [error] [client 127.5.108.1]     self._setup()
[Fri Jul 19 18:09:15 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/conf/__init__.py", line 42, in _setup
[Fri Jul 19 18:09:15 2013] [error] [client 127.5.108.1]     self._wrapped = Settings(settings_module)
[Fri Jul 19 18:09:15 2013] [error] [client 127.5.108.1]   File "/var/lib/openshift/51cb0e515004460d6f000131/python/virtenv/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/conf/__init__.py", line 95, in __init__
[Fri Jul 19 18:09:15 2013] [error] [client 127.5.108.1]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Fri Jul 19 18:09:15 2013] [error] [client 127.5.108.1] ImportError: Could not import settings 'digrin.settings' (Is it on sys.path?): No module named openshiftlibs

==> python/logs/access_log-20130718-000000-EST <==
95.102.233.230 - - [18/Jul/2013:16:14:17 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
95.102.233.230 - - [18/Jul/2013:16:14:18 -0400] "GET /favicon.ico HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
95.102.233.230 - - [18/Jul/2013:16:14:20 -0400] "GET /favicon.ico HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
95.102.233.230 - - [18/Jul/2013:16:15:39 -0400] "GET / HTTP/1.1" 500 627 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"

==> postgresql/log/postgresql-Sat.log <==

==> postgresql/log/postgresql-Fri.log <==
LOG:  trying another address for the statistics collector
LOG:  could not bind socket for statistics collector: Cannot assign requested address
LOG:  trying another address for the statistics collector
LOG:  could not bind socket for statistics collector: Cannot assign requested address
LOG:  disabling statistics collector for lack of working socket
WARNING:  autovacuum not started because of misconfiguration
HINT:  Enable the "track_counts" option.
LOG:  database system was shut down at 2013-07-19 11:01:07 EDT
FATAL:  the database system is starting up
LOG:  database system is ready to accept connections

==> postgresql/log/postgresql-Sun.log <==
LOG:  received smart shutdown request
LOG:  shutting down
LOG:  database system is shut down

==> postgresql/log/postgresql-Thu.log <==
LOG:  could not bind socket for statistics collector: Permission denied
LOG:  trying another address for the statistics collector
LOG:  could not bind socket for statistics collector: Cannot assign requested address
LOG:  trying another address for the statistics collector
LOG:  could not bind socket for statistics collector: Cannot assign requested address

LOG:  disabling statistics collector for lack of working socket
WARNING:  autovacuum not started because of misconfiguration
HINT:  Enable the "track_counts" option.
LOG:  database system was shut down at 2013-07-17 12:06:26 EDT
LOG:  database system is ready to accept connections

==> postgresql/log/postgresql-Wed.log <==
LOG:  trying another address for the statistics collector
LOG:  could not bind socket for statistics collector: Cannot assign requested address
LOG:  trying another address for the statistics collector
LOG:  could not bind socket for statistics collector: Cannot assign requested address
LOG:  disabling statistics collector for lack of working socket
WARNING:  autovacuum not started because of misconfiguration
HINT:  Enable the "track_counts" option.
FATAL:  the database system is starting up
LOG:  database system was shut down at 2013-07-21 18:03:08 EDT
LOG:  database system is ready to accept connections

这是我的应用程序wsgi / application

#!/usr/bin/env python

import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'digrin.settings'
sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'wsgi', 'digrin'))
virtenv = os.environ['APPDIR'] + '/virtenv/'
os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python2.6/site-packages')
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
    execfile(virtualenv, dict(__file__=virtualenv))
except:
    pass

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

我收到500内部服务器错误

2 个答案:

答案 0 :(得分:1)

阅读此博文 http://appsembler.com/blog/django-deployment-using-openshift/

它提供了在OpenShift上启动django应用程序的最佳解释

答案 1 :(得分:0)

我不知道我必须重新加载配置。所以rhc app reload -a $your_app做了伎俩。也可能是这一行:sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'wsgi'))。感谢bezidejni的帮助,指出启用调试也很有用:)