1

サーバーに Django プロジェクトをデプロイしようとしています。virtualenv を有効にして Django をデプロイしています。

apache2ログから得たエラーはこちら

[Wed Aug 07 04:25:19 2013] [error]     __import__(name)
[Wed Aug 07 04:25:19 2013] [error]   File "/var/www/projects/openstack-horizon/openstack_dashboard/dashboards/project/access_and_security/urls.py", line 31, in <module>
[Wed Aug 07 04:25:19 2013] [error]     from openstack_dashboard.dashboards.project.access_and_security.\\
[Wed Aug 07 04:25:19 2013] [error]   File "/var/www/projects/openstack-horizon/openstack_dashboard/dashboards/project/access_and_security/security_groups/urls.py", line 24, in <module>
[Wed Aug 07 04:25:19 2013] [error]     from openstack_dashboard.dashboards.project.access_and_security.\\
[Wed Aug 07 04:25:19 2013] [error]   File "/var/www/projects/openstack-horizon/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py", line 37, in <module>
[Wed Aug 07 04:25:19 2013] [error]     from openstack_dashboard.dashboards.project.access_and_security.\\
[Wed Aug 07 04:25:19 2013] [error]   File "/var/www/projects/openstack-horizon/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py", line 35, in <module>
[Wed Aug 07 04:25:19 2013] [error]     from horizon.utils.validators import validate_ip_protocol
[Wed Aug 07 04:25:19 2013] [error] ImportError: cannot import name validate_ip_protocol

ここに私が得た完全なトレースバックがあります

Environment:


Request Method: GET
Request URL: http://192.168.1.150:8060/

Django Version: 1.4.5
Python Version: 2.7.3
Installed Applications:
('openstack_dashboard',
 'django.contrib.contenttypes',
 'django.contrib.auth',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'compressor',
 'horizon',
 'openstack_dashboard.dashboards.project',
 'openstack_dashboard.dashboards.admin',
 'openstack_dashboard.dashboards.settings',
 'openstack_auth')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'horizon.middleware.HorizonMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  89.                     response = middleware_method(request)
File "/usr/lib/python2.7/dist-packages/django/middleware/locale.py" in process_request
  21.         check_path = self.is_language_prefix_patterns_used()
File "/usr/lib/python2.7/dist-packages/django/middleware/locale.py" in is_language_prefix_patterns_used
  54.         for url_pattern in get_resolver(None).url_patterns:
File "/usr/lib/python2.7/dist-packages/django/core/urlresolvers.py" in url_patterns
  328.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/lib/python2.7/dist-packages/django/core/urlresolvers.py" in urlconf_module
  323.             self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/var/www/projects/openstack-horizon/openstack_dashboard/urls.py" in <module>
  38.     url(r'', include(horizon.urls))
File "/usr/lib/python2.7/dist-packages/django/conf/urls/__init__.py" in include
  25.     patterns = getattr(urlconf_module, 'urlpatterns', urlconf_module)
File "/usr/lib/python2.7/dist-packages/django/utils/functional.py" in inner
  184.             self._setup()
File "/usr/lib/python2.7/dist-packages/django/utils/functional.py" in _setup
  248.         self._wrapped = self._setupfunc()
File "/usr/lib/python2.7/dist-packages/horizon/base.py" in url_patterns
  715.             return self._urls()[0]
File "/usr/lib/python2.7/dist-packages/horizon/base.py" in _urls
  746.                     url(r'^%s/' % dash.slug, include(dash._decorated_urls)))
File "/usr/lib/python2.7/dist-packages/horizon/base.py" in _decorated_urls
  456.                     url(r'^%s/' % panel.slug, include(panel._decorated_urls)))
File "/usr/lib/python2.7/dist-packages/horizon/base.py" in _decorated_urls
  230.         urlpatterns = self._get_default_urlpatterns()
File "/usr/lib/python2.7/dist-packages/horizon/base.py" in _get_default_urlpatterns
  83.                 urls_mod = import_module('.urls', package_string)
File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/var/www/projects/openstack-horizon/openstack_dashboard/dashboards/admin/instances/urls.py" in <module>
  24. from openstack_dashboard.dashboards.admin.instances.views import AdminIndexView
File "/var/www/projects/openstack-horizon/openstack_dashboard/dashboards/admin/instances/views.py" in <module>
  31. from openstack_dashboard.dashboards.admin.instances.tables import \
File "/var/www/projects/openstack-horizon/openstack_dashboard/dashboards/admin/instances/tables.py" in <module>
  25. from horizon.utils.filters import parse_isotime

Exception Type: ImportError at /
Exception Value: cannot import name parse_isotime

これが私の仮想ホストです

<VirtualHost *:8060>
        ServerAdmin jonathan.c@advitor.com
        ServerName automation-cloud.com
        ServerAlias www.automation-cloud.com
        WSGIScriptAlias / var/www/projects/openstack-horizon/horizon.wsgi

        Alias /static/ /var/www/projects/openstack-horizon/openstack_dashboard/static/
        <Location "/static/">
            Options -Indexes
        </Location>
</VirtualHost>

ここに私のHorizo​​n.wsgiファイルがあります

import os
import sys
import site

# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('/var/www/projects/openstack-horizon/.venv/local/lib/python2.7/site-packages')

# Add the app's directory to the PYTHONPATH
sys.path.append('/var/www/projects/openstack-horizon')
#sys.path.append('/var/www/projects/openstack-horizon/horizon')
sys.path.append('/var/www/projects/openstack-horizon/openstack_dashboard')
#/usr/lib/python2.7/dist-packages/horizon/
sys.path.append('/usr/lib/python2.7/dist-packages/horizon')
os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings'

# Activate your virtual env
activate_env=os.path.expanduser("/var/www/projects/openstack-horizon/.venv/bin/activate_this.py")
execfile(activate_env, dict(__file__=activate_env))

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

私はすべてをチェックします、Horizo​​nアプリはsettings.pyにあります

この Django プロジェクトは、アクティブ化された python manage.py runserver virtualenv を実行すると正常に動作します。

4

1 に答える 1

1

Apache が仮想環境にアドレス指定していません。エラートレースの最初の行を確認してください

/usr/lib/python2.7/dist-packages/django/core/handlers/base.py

仮想環境ではなく、デフォルトのpythonの場所を指しています。これを試して、仮想環境パスを含めます。

sys.path.append('/var/www/projects/openstack-horizon/.venv/local/lib/python2.7/site-packages')

よろしく

アンシュ・ジェイン

于 2013-08-07T07:13:54.630 に答える