2013-08-07 48 views
1

我想在我的服務器上部署Django項目,我正在部署與激活virtualenv的Django。無法在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 [email protected] 
     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> 

繼承人我的視野。 wsgi文件

0運行蟒蛇manage.py runserver命令的virtualenv激活時

我檢查一切,地平線應用程序是在settings.py

這個Django項目工作正常。

+0

這些都是進口的錯誤。也許你忘了追加一個路徑到你的sys.path? –

+0

其實我有sys.path.append('/ var/www/projects/openstack-horizo​​n') –

回答

1

Apache沒有解決您的虛擬環境問題。檢查你的錯誤跟蹤的第一行

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

它指向默認的python位置不是你的虛擬env。 試試這個包含虛擬env路徑。

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

問候

ANSH耆那教