1

当我尝试在 openshift 上启动我的 django 应用程序时,我收到以下消息。因此部署失败......

File "wsgi/djangoProjectNew/manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
File "/var/lib/openshift/55555511111114444444444/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
File "/var/lib/openshift/55555511111114444444444/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/__init__.py", line 312, in execute
    django.setup()
File "/var/lib/openshift/55555511111114444444444/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
File "/var/lib/openshift/55555511111114444444444/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
File "/var/lib/openshift/55555511111114444444444/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/apps/config.py", line 119, in create
    import_module(entry)
File "/opt/rh/python27/root/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named django

这个应用程序是我几个月前设置的应用程序的副本。我更改了所有相关的路径、名称等。它在本地运行良好。

最后一个命令 __init__.py 在 vi​​rtualenv 之外运行是不是很奇怪?

我正在使用 python2.7 墨盒和 github openshift 示例https://github.com/openshift/django-example这个应用程序使用 django 1.8.0 作为依赖项。

这是从 djangoProject.settings 安装的应用程序

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'myDjangoApp',
    'djcelery',
    'kombu.transport.django',
    'progressbarupload',
    'widget_tweaks',
)

Django 已安装:

[djangoProject-USERNAME.rhcloud.com data]\> which python
/var/lib/openshift/55555511111114444444444/python/virtenv/bin/python
[djangoProject-USERNAME.rhcloud.com data]\> python 
Python 2.7.8 (default, Aug  4 2016, 09:29:33) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 8, 0, 'final', 0)
>>> 

在进一步玩弄之后,我可以说它与这些 INSTALLED_APPS 中的一个或全部有关:

    'djcelery',
    'kombu.transport.django',
    'progressbarupload',

这是点冻结:

amqp==2.1.1
Babel==0.9.6
billiard==3.5.0.1
celery==4.0.0rc6
Django==1.8
django-celery==3.1.17
django-smartfields==1.0.9
django-widget-tweaks==1.4.1
docutils==0.11
Extractor==0.6
Jinja2==2.6
kombu==4.0.0rc6
MarkupSafe==0.11
MySQL-python==1.2.3
nose==1.3.0
numpy==1.7.1
prelive==1.0
psycopg2==2.5.1
Pygments==1.5
pytz==2016.7
scipy==0.12.1
simplejson==3.2.0
six==1.7.3
Sphinx==1.1.3
SQLAlchemy==0.7.9
vine==1.1.3
virtualenv==13.1.0
Werkzeug==0.8.3
wheel==0.24.0
4

2 回答 2

1

原因是 'kombu.transport.django' 在 kombu 4.0.0 中不再可用。

所以“ImportError: No module named django”是抱怨 package 中的一个模块kombu,而不是 package Django

使用kombu 3.0.** 应该可以修复它。

于 2016-12-01T16:51:51.143 回答
0

我将此添加到我的 setup.py 中,现在它可以工作了。

install_requires=[
    'Django==1.8', 
    'django-celery==3.1.16', 
    'kombu==3.0.26', 
    'django-widget-tweaks==1.4.1', 
    'celery==3.1.18', 
    'django-crispy-forms==1.4.0', 
    ],
于 2016-11-23T21:38:21.853 回答